>  Q&A  >  본문

oci_parse() 메서드는 null 구문 분석 메서드를 반환합니다.

몇 가지 OCI 메소드를 사용하여 ORACLE 데이터베이스에 연결하는 클래스를 만들고 싶습니다.

하지만 Parse() 메서드를 호출하면 null이 되고 FetchArray() 메서드는 아무것도 반환하지 않습니다

데이터베이스 PHP 클래스:

으아아아

테스트 페이지.php:

으아아아

현재 데이터베이스 연결에 성공했습니다.

배열 가져오기 방법:

class Database
{
    /**
     * @var string
     */
    private string $login;
    /**
     * @var string
     */
    private string $password;
    /**
     * @var string
     */
    private string $description;
    /**
     * @var
     */
    private $connection;
    /**
     * @var
     */
    private $stmt;

    public function __construct(string $login, string $password, string $description)
    {
        $this->login = $login;
        $this->password = $password;
        $this->description = $description;
    }


    public function Connection($character_set = null, $session_mode = null)
    {
        $this->connection = oci_connect($this->login, $this->password, $this->description, $character_set,    $session_mode);
    }

   
    public function Parse(string $sql)
    {
        $this->stmt = oci_parse($this->connection, $sql);
    }


    public function Execute()
    {
        oci_execute($this->stmt);
    }

P粉043432210P粉043432210238일 전340

모든 응답(1)나는 대답할 것이다

  • P粉571233520

    P粉5712335202024-01-30 09:20:38

    문제를 발견한 것 같아요. while 조건에서 행 데이터를 가져온 결과를 부울 false와 비교하기 위해 몇 가지 괄호를 놓쳤을 수 있습니다.

    으아아아

    이 줄이 업데이트되었습니다:

    으아아아

    get 함수에서 유형 변환을 제거하는 것도 안전하다고 생각합니다

    으아아아

    회신하다
    0
  • 취소회신하다