简体   繁体   中英

php: execute query with PDO OCI

I'm trying execute simple script, but can't get result.

$id = $_GET['contract'];
$dsn = 'oci:dbname=xxx.xxx.xx';
$user = 'xxxx';
$pass = 'xxxx';

try{
    $conn = new PDO($dsn, $user, $pass);

    $stmt = $conn->prepare('SELECT * FROM DOGOVOR.CONTRACT CTR WHERE CTR.CONTRACTORNUMDOC = ?');
    $stmt->execute(array($id));
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
}
catch (PDOException $e){
    echo $e->getMessage();
}

var_dump($row);

result - bool(false). None errors. If i try query only "SELECT * FROM DOGOVOR.CONTRACT", then all ok. Need to say that $id take cyrilic value. May it be problem with charset or something else? Oracle 9i. PHP 5.2.

Try this query:

SELECT CTR.* FROM DOGOVOR.CONTRACT CTR WHERE CTR.CONTRACTORNUMDOC = ?

Here you missed CTR.*

or simpler:

SELECT * FROM DOGOVOR.CONTRACT WHERE CONTRACTORNUMDOC = ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM