v5:reference:connection:getone
getOne
Syntax
mixed getOne( string $sql, optional string[] $bindvars )
Executes the SQL and returns the first column of the first row. The recordset and remaining rows are discarded for you automatically. If an error occurs, either false or null is returned depending on the value of $ADODB_GETONE_EOF.
You can use errorMsg() to get any the error details.
Controlling the response if no records are found
By default, getOne returns NULL if no records are found. The global variable $ADODB_GETONE_EOF
can be set to any value to indicate no match
Usage
$ADODB_GETONE_EOF = "-1"; $SQL = "SELECT MAX(tickets) FROM arena WHERE zip_code = '80111'"; $maxTickets = $db->GetOne($SQL); if ($maxTickets == -1) print "There are no arenas in zip code 80111"; elseif ($maxTickets == 0) print "No tickets have been sold in zip code 80111"; else print "The maximum number of tickets sold by arenas in Zip Code 80111 is $maxTickets";
v5/reference/connection/getone.txt · Last modified: 2021/03/11 20:15 by dregad