ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:getinsertsql

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:getinsertsql [2015/09/12 18:15] – [$fieldArray] mnewnhamv5:reference:connection:getinsertsql [2021/01/25 03:16] (current) mnewnham
Line 1: Line 1:
 ====== getInsertSql ====== ====== getInsertSql ======
 +~~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]]\\ 
-[[reference:adodb_force_type|$ADODB_FORCE_TYPE]]\\ +[[v5:reference:adodb_force_type|$ADODB_FORCE_TYPE]]\\ 
-[[reference:autoexecute|AutoExecute()]]\\+[[v5:reference:connection:autoexecute|AutoExecute()]]\\
  
  
Line 12: Line 12:
         mixed $recordSet,         mixed $recordSet,
         string[] $fieldArray,         string[] $fieldArray,
-        optional bool $dontFixQuotes=false,+        optional bool $placeholder=false,
         optional bool $forceType=null         optional bool $forceType=null
        )        )
Line 21: Line 21:
 ===== Parameters ===== ===== Parameters =====
 ====  $recordSet ==== ====  $recordSet ====
-The parameter ''$recordSet'' is _either a recordset obtained by [[reference:execute|executing]] a select statement to obtain an **invalid record**. There is no need to read the row.+The parameter ''$recordSet'' is either 
  
-<code php>+  * a //recordset// obtained by [[v5:reference:connection:execute|executing]] a select statement to obtain an **empty recordset**. There is no need to read the row. <code php>
 $SQL = "SELECT * FROM employees WHERE emp_no=-1"; $SQL = "SELECT * FROM employees WHERE emp_no=-1";
 $result = $db->execute($SQL); $result = $db->execute($SQL);
 $sql = $db->getInsertSql($result,..... $sql = $db->getInsertSql($result,.....
 </code> </code>
-or +   
-<code php>+  * a //string// specifying a table name <code php>
 $table = 'employees'; $table = 'employees';
 $sql = $db->getInsertSql($table,.... $sql = $db->getInsertSql($table,....
-</code> +</code> Note that in this casedue to the fact that the function passes the table name by reference, the following syntax is //not valid//: <code php>
-Note that in the second instancebecause the function passes the table name by reference, the following syntax is not valid+
-<code php>+
 /* /*
  * Incorrect syntax  * Incorrect syntax
  */  */
 $sql = $db->getInsertSql('employees',.... $sql = $db->getInsertSql('employees',....
-</code> +</code> Also note that this usage causes ADOdb to read the recordset information for itself, which may cause performance issues.
- +
-Also note that in the second example, ADOdb must attempt to read the recordset information for itself, and there may be performance issues.+
  
 ==== $fieldArray ==== ==== $fieldArray ====
 ''$fieldArray'' is an associative key=>value pair of fieldnames and values. The values in the pair will be inserted into the record. Note also ''$fieldArray'' is an associative key=>value pair of fieldnames and values. The values in the pair will be inserted into the record. Note also
   * Any key in the array that does not match a field name in the table will be discarded before the SQL statement is produced.   * Any key in the array that does not match a field name in the table will be discarded before the SQL statement is produced.
-  * The value of any field in the table that does not appear in the ''$fieldArray'' is controlled by the [[reference:adodb_force_type|$ADODB_FORCE_TYPE]] variable.+  * The value of any field in the table that does not appear in the ''$fieldArray'' is controlled by the [[v5:reference:adodb_force_type|$ADODB_FORCE_TYPE]] variable.
   * Auto-increment fields should not be included in the field list.   * Auto-increment fields should not be included in the field list.
  
Line 53: Line 49:
 </code> </code>
 ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-<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 previosly held information about now-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 64: Line 57:
 ==== $forceType ==== ==== $forceType ====
  
-see [[reference:adodb_force_type|$ADODB_FORCE_TYPE]]+see [[v5:reference:adodb_force_type|$ADODB_FORCE_TYPE]]
 ------------------------------------------- -------------------------------------------
 ===== Usage ===== ===== Usage =====
v5/reference/connection/getinsertsql.1442074528.txt.gz · Last modified: 2017/04/21 11:35 (external edit)