|
Posted by Toby Inkster on 01/18/07 17:17
Sonnich wrote:
> try
> $result=odbc_exec($conn, $sql2);
> $error=false;
> except
> $error=true;
> end
> while( !$error && odbc_fetch_row($result) )
Take a look at PDO. It's the new PHP 5 way of accessing databases, using a
unified syntax for all database engines (no need to worry about
mysql_query vs pg_query vs odbc_exec!)
*And* it uses Exceptions which can be handled pretty much like you
describe.
<?php
try
{
$db = new PDO ($connection_string, $username, $password);
$result = $db->query($sql_query);
foreach ($result as $row)
{
/* Do something */
}
}
catch (Exception $e)
{
print "Something bad happened", $e, "\n";
}
?>
You like?
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Navigation:
[Reply to this message]
|