oci_parse的返回值

问题描述:

如果我想在里面执行一些命令,如果查询没有返回行,if的条件是什么。oci_parse的返回值

<?php 
    include_once('config.php'); 
    $db = oci_new_connect(ORAUSER,ORAPASS,"localhost/XE"); 
    $sql="select * from table_1 where id=3"; 
    $result=oci_parse($db,$sql); 
    oci_result($result); 

    if() 
    { 

    } 
    else 
    { 

    } 
?> 

你可以使用oci_fetch

// parse/bind your statement 

if (oci_fetch($your_statement)) { 
    ... // do something when there is rows 
}  
else { 
    ... // do something when there is no rows 
} 
+0

相信OP是指运行语句不返回行的,如插入,更新,程序... – 2010-02-02 15:42:39

+0

感谢的Malgrat它的工作.... .....十分感谢.......... – user256938 2010-02-02 16:26:21

与oci_parse分配绑定值后(),您需要与oci_execute()运行查询。这是函数的定义:

布尔oci_execute(资源 $语句[摘要$模式= OCI_COMMIT_ON_SUCCESS])成功

返回TRUE或FALSE的失败。

全部放在一起:

<?php 

$stmt = oci_parse($conn, $sql); 
$res = oci_execute($stmt); 
if(!$res){ 
    $error = oci_error($stmt); 
    echo "Error: " . $error['message'] . "\n"; 
}else{ 
    echo "OK\n"; 
} 

?>