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
reference:getupdatesql [2015/10/14 16:41] mnewnhamv5:reference:connection:getupdatesql [2023/09/26 17:43] (current) – Fix broken link to execute() page dregad
Line 3: Line 3:
 <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 ==
Line 10: Line 10:
         string[] $fieldArray,         string[] $fieldArray,
         optional bool $forceUpdate=false,         optional bool $forceUpdate=false,
-        optional bool $dontFixQuotes=false,+        optional bool $placeHolder=false,
         optional bool $forceType=null         optional bool $forceType=null
        )        )
Line 19: Line 19:
 ===== Parameters ===== ===== Parameters =====
 ====  $result==== ====  $result====
-The parameter ''$result'' is the handle to the result obtained by [[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.+The parameter ''$result'' is the handle to the result obtained by [[v5:reference:connection: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 29: 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:connection:execute]] to fail if passed this parameter.
 ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-<WRAP right tip 300px> +==== $placeHolder ==== 
-Use of this parameter is tied to the now removed ''magic_quotes'' functionality and this parameter may be removed in future releases of ADOdb +This argument was previously used for information about deprecated PHP functionality, and is now ignored 
-</WRAP> +
-==== $dontFixQuotes ==== +
-For a description of this behavior see [[reference:qstr|qStr()]].+
 -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
 <WRAP right tip 300px> <WRAP right tip 300px>
Line 46: Line 45:
 ==== $forceType ==== ==== $forceType ====
  
-see [[reference:adodb_force_type|$ADODB_FORCE_TYPE]]+see [[v5:reference:adodb_force_type|$ADODB_FORCE_TYPE]]
 ------------------------------------------- -------------------------------------------
 ===== Usage ===== ===== Usage =====
Line 70: Line 69:
  
 $SQL = 'SELECT * FROM employees WHERE emp_no=10001'; $SQL = 'SELECT * FROM employees WHERE emp_no=10001';
-$result = $db->Execute($SQL);+$result = $db->execute($SQL);
  
 $updateArray = array('first_name'=>'Jerry', $updateArray = array('first_name'=>'Jerry',
Line 76: Line 75:
       'gender'=>'M');       'gender'=>'M');
  
-$SQL = $db->getUpdateSql($result,$updateArray); +$SQL = $db->getUpdateSql($result, $updateArray);
- +
-print $SQL+
 /* /*
- * returnsUPDATE 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 89: Line 90:
  
 <code php> <code php>
-$SQL = $db->getUpdateSql($result,$updateArray.true);+$SQL = $db->getUpdateSql($result, $updateArraytrue);
 /* /*
  * 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.1444833665.txt.gz · Last modified: 2017/04/21 11:34 (external edit)