[英]Return value of oci_parse
what will be the condition of if , where i want to execute some command inside if ,if there is no row returned by the query. if的条件是什么,如果没有查询返回的行,我想在if中执行一些命令。
<?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
{
}
?>
After assigning the bind values with oci_parse(), you need to run the query with oci_execute() . 在使用oci_parse()分配绑定值之后,您需要使用oci_execute()运行查询。 This is the function definition:
这是函数定义:
bool oci_execute ( resource $statement [, int $mode = OCI_COMMIT_ON_SUCCESS ] )
bool oci_execute(资源$ statement [,int $ mode = OCI_COMMIT_ON_SUCCESS])
Returns TRUE on success or FALSE on failure.
成功返回TRUE,失败返回FALSE。
Putting it all together: 放在一起:
<?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";
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.