ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:getone

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
reference:getone [2015/10/09 23:19] mnewnhamv5:reference:connection:getone [2021/03/11 20:15] (current) – [getOne] syntax: Added missing $bindvars param dregad
Line 1: Line 1:
-====== GetOne =====+====== getOne =====
 ~~NOTOC~~ ~~NOTOC~~
  
Line 5: Line 5:
 == Syntax == == Syntax ==
     mixed getOne(     mixed getOne(
-       string $sql+       string $sql
 +       optional string[] $bindvars
        )        )
  
 </WRAP> </WRAP>
    
 +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]]. 
  
-Executes the SQL and returns the first field of the first row. The recordset and remaining rows are discarded for you automatically. If an error occur either false or null is returned depending on the value of [[reference:$ADODB_GETONE_EOF]]. use [[reference:errno|errorNo()]] or [[reference:errormsg|errorMsg()]] to get the error details. +You can use [[v5:reference:errormsg|errorMsg()]] to get any the error details. 
  
 ===== Controlling the response if no records are found ===== ===== 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+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 ===== ===== Usage =====
Line 29: Line 31:
     print "No tickets have been sold in zip code 80111";     print "No tickets have been sold in zip code 80111";
 else else
-    print "The maximum number of tickets sold by arenas in Zip Code 80111 is $maxTickets";+    print "The maximum number of tickets sold by arenas  
 +           in Zip Code 80111 is $maxTickets";
 </code> </code>
  
-<WRAP warning> 
-Warning - If an SQL error occurs, getOne() may still return correctly. 
-</WRAP> 
  
v5/reference/connection/getone.1444425558.txt.gz · Last modified: 2017/04/21 11:34 (external edit)