ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:getupdatesql

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
Next revisionBoth sides next revision
reference:getupdatesql [2015/07/25 23:47] mnewnhamv5:reference:connection:getupdatesql [2016/01/16 22:15] – ↷ Page moved from v5:reference:getupdatesql to v5:reference:connection:getupdatesql mnewnham
Line 1: Line 1:
 ====== getUpdateSql ====== ====== getUpdateSql ======
 +~~NOTOC~~
 <WRAP right box> <WRAP right box>
 == See Also == == See Also ==
-[[reference:adodb_quote_fieldnames|$ADODB_QUOTE_FIELDNAMES]]+[[v5:reference:adodb_quote_fieldnames|$ADODB_QUOTE_FIELDNAMES]]
  
 == Syntax == == Syntax ==
   string getUpdateSql(   string getUpdateSql(
-        obj $recordSet,+        obj $result,
         string[] $fieldArray,         string[] $fieldArray,
         optional bool $forceUpdate=false,         optional bool $forceUpdate=false,
Line 16: Line 16:
 ===== Description ===== ===== Description =====
 The function ''getUpdateSql()'' takes a set of parameters and returns an SQL statement that can be used to update a record in the database. It can automatically apply any necessary database specific quoting to character fields and exclude any unchanged variables. The function ''getUpdateSql()'' takes a set of parameters and returns an SQL statement that can be used to update a record in the database. It can automatically apply any necessary database specific quoting to character fields and exclude any unchanged variables.
 +------------------
 ===== Parameters ===== ===== Parameters =====
-====  $recordSet ==== +====  $result==== 
-The parameter ''$recordSet'' is the recordset obtained by [[reference:execute|executing]] a select statement to obtain the record. There is no need to read the row.+The parameter ''$result'' is the handle to the result obtained by [[v5:reference:execute|executing]] a select statement to obtain the record, **not the recordset associated with the request**. There is no need to read the row.
  
 <code php> <code php>
Line 28: Line 29:
 ''$fieldArray'' is an associative key=>value pair of fieldnames and values. The values in the pair will replace the values in the existing record ''$fieldArray'' is an associative key=>value pair of fieldnames and values. The values in the pair will replace the values in the existing record
 <code php> <code php>
-$ar = array('actname',"John O'Reilly");+$ar = array('actname'=>"John O'Reilly");
 </code> </code>
 -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
 ==== $forceUpdate ==== ==== $forceUpdate ====
-''$forceUpdate'' forces the sql statement to include updates for fields that have not changed.+''$forceUpdate'' forces the sql statement to include updates for fields that have not changed. It may be necessary to force updates when, for example, distinction needs to be made between null and zero in integer fields. 
 + 
 +In addition, use of this parameter eliminates the need to add additional testing to determine if any fields have changed. In cases such as these, if the parameter is not set and there have been no modified fields, the getUpdateSql() method will return an empty string, causing [[v5:reference:execute]] to fail if passed this parameter.
 ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
 <WRAP right tip 300px> <WRAP right tip 300px>
Line 38: Line 41:
 </WRAP> </WRAP>
 ==== $dontFixQuotes ==== ==== $dontFixQuotes ====
-For a description of this behavior see [[reference:qstr|qStr()]].+For a description of this behavior see [[v5:reference:qstr|qStr()]].
 -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
 <WRAP right tip 300px> <WRAP right tip 300px>
-This parameter was designed to provide backwards with now unsupported versions of ADOdb and may be removed in future releases.+This parameter was designed to provide backwards compatibility with now unsupported versions of ADOdb and may be removed in future releases.
 </WRAP> </WRAP>
 ==== $forceType ==== ==== $forceType ====
  
-see [[reference:adodb_force_type|$ADODB_FORCE_TYPE]]+see [[v5:reference:adodb_force_type|$ADODB_FORCE_TYPE]]
 ------------------------------------------- -------------------------------------------
 ===== Usage ===== ===== Usage =====
Line 79: Line 82:
 print $SQL print $SQL
 /* /*
- * returns: UPDATE employees SET FIRST_NAME='Jerry', LAST_NAME='O\'reilly' WHERE emp_no=10001+ * returns: UPDATE employees  
 +              SET FIRST_NAME='Jerry',  
 +                  LAST_NAME='O\'reilly'  
 +            WHERE emp_no=10001
  */  */
 </code> </code>
Line 91: Line 97:
 /* /*
  * returns  * returns
- * UPDATE employees SET FIRST_NAME='Jerry', LAST_NAME='O\'reilly', GENDER='M' WHERE emp_no=10001+ * UPDATE employees SET FIRST_NAME='Jerry',  
 +                        LAST_NAME='O\'reilly',  
 +                        GENDER='M'  
 +                        WHERE emp_no=10001
  */  */
 </code> </code>
v5/reference/connection/getupdatesql.txt · Last modified: 2023/09/26 17:43 by dregad