logo       

RE: Mysql C API problems: msg#01140

db.mysql.general

Subject: RE: Mysql C API problems

> 1 - if i wanna make an action based on the fact that a query i just
made
> won't return results (empty set), how can i test that?
>
> will this do?
> if(!mysql_query(myData, query)
> {
> results = mysql_store_results(myData);
>
> if(mysql_num_rows() == 0)
> {
> //action;
> }
> }

That's right, except mysql_num_rows() takes a pointer to the results you
get from mysql_store_results(), so it looks like this:

if( mysql_num_rows( result ) == 0 )
{
// action
}

> 2 - if the the row is made of one single field wich in turn is an
integer,
> how can i address to it's value?

Like this:

MYSQL_ROW row = mysql_fetch_row( result );
int value = atoi( row[0] );

Dean Harding


---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <mysql-thread113389@xxxxxxxxxxxxxxx>
To unsubscribe, e-mail
<mysql-unsubscribe-gcdmg-mysql=m.gmane.org@xxxxxxxxxxxxxxx>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise