Re: [phplib] test for database SQL success or failure From: Layne Weathers (layne <email protected>)
Date: 03/13/01

> I'm looking for a way to test whether or not a call to phplib query
> function has succeeded or failed.
>
> if i call the 'query' function ie. $db->query( "SQL" );
>
> what can I do next to test the "pass" or "fail" of the SQL statement.

Depending on the circumstances

  if($db->num_rows()) { ... }

or

  if($db->next_record()) { ... }

You could also use a preliminary query to find the number of matching rows.

  $db->query("select count(*) from table where ...");
  $db->next_record();
  if($db->f(0)) { ... }

Layne Weathers
Ifworld, Inc.
layne <email protected>

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>