====== getOne =====
~~NOTOC~~
== 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 [[v5:reference:adodb_getone_eof]].
You can use [[v5:reference:errormsg|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";