PHP - Execute an update using a parameter
From Ingres Community Wiki
<?php
$database='dbname';
$user='user';
$password='password';
$conn = ingres_connect($database,$user,$password);
if ($conn) {
echo "Connection succeeded.";
$param = array(1,1.1,"Row 1");
$rc=ingres_query($conn,"insert into param_tests values (?,?,?)",$param);
if (is_resource($rc)) {
echo "Insert succeeded.";
$param = array ("col2"=>2.2,"col3"=>"Row 2","col1"=> 1);
$rc=ingres_query($conn,"update param_tests set col2=?, col3=? where col1=?",$param);
if (ingres_errno() != 0)
{
echo "Update failed.";
}
else
{
echo "Update succeeded.";
}
$param = array(1);
$rc=ingres_query($conn,"select * from param_tests where col1 = ?",$param);
if (is_resource($rc)) {
while ( $object = ingres_fetch_object($rc)) {
echo $object->col1 . " " . $object->col2 . " " . $object->col3 .".";
}
}
} else {
echo "Insert failed.";
}
ingres_close($conn);
} else {
echo "Connection failed.";
}
?>
Back to PHP Driver Examples
