v5:reference:connection:getupdatesql
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
reference:getupdatesql [2015/07/25 16:15] – created mnewnham | reference:getupdatesql [2016/01/04 23:34] – [Usage] mnewnham | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== getUpdateSql ====== | ====== getUpdateSql ====== | ||
+ | ~~NOTOC~~ | ||
<WRAP right box> | <WRAP right box> | ||
== See Also == | == See Also == | ||
Line 7: | Line 7: | ||
== Syntax == | == Syntax == | ||
string getUpdateSql( | string getUpdateSql( | ||
- | | + | |
string[] $fieldArray, | string[] $fieldArray, | ||
optional bool $forceUpdate=false, | optional bool $forceUpdate=false, | ||
- | optional bool $magicQuotes=false, | + | optional bool $dontFixQuotes=false, |
- | optional bool $forceType=false | + | optional bool $forceType=null |
) | ) | ||
</ | </ | ||
===== Description ===== | ===== Description ===== | ||
The function '' | The function '' | ||
+ | ------------------ | ||
===== Parameters ===== | ===== Parameters ===== | ||
- | ==== $recordSet | + | ==== $result==== |
- | The parameter '' | + | The parameter '' |
- | === Acceptable Methods Of Passing Parameter 1 === | + | |
- | <code php> | + | |
- | $table = ' | + | |
- | $sql = $db-> | + | |
- | </ | + | |
- | or | + | |
<code php> | <code php> | ||
- | $SQL = " | + | $SQL = " |
$result = $db-> | $result = $db-> | ||
$sql = $db-> | $sql = $db-> | ||
</ | </ | ||
- | === Uncceptable Methods Of Passing Parameter 1 === | + | ==== $fieldArray |
+ | '' | ||
<code php> | <code php> | ||
- | + | $ar = array('actname' | |
- | $sql = $db-> | + | |
</ | </ | ||
- | or | + | -------------------------------------------------------------------------------- |
+ | ==== $forceUpdate ==== | ||
+ | '' | ||
+ | |||
+ | 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 [[reference: | ||
+ | ------------------------------------------------------------------------------- | ||
+ | <WRAP right tip 300px> | ||
+ | Use of this parameter is tied to the now removed '' | ||
+ | </ | ||
+ | ==== $dontFixQuotes ==== | ||
+ | For a description of this behavior see [[reference: | ||
+ | -------------------------------------------------------------------------------- | ||
+ | <WRAP right tip 300px> | ||
+ | This parameter was designed to provide backwards compatibility with now unsupported versions of ADOdb and may be removed in future releases. | ||
+ | </ | ||
+ | ==== $forceType ==== | ||
+ | |||
+ | see [[reference: | ||
+ | ------------------------------------------- | ||
+ | ===== Usage ===== | ||
<code php> | <code php> | ||
- | $SQL = " | + | /* |
- | $result = $db->selectLimit($SQL,1); | + | * Sample uses the MySQL ' |
- | $sql = $db-> | + | */ |
+ | |||
+ | $SQL = " | ||
+ | $employeeRecord = $db-> | ||
+ | /* | ||
+ | * Employee record returns: | ||
+ | Array | ||
+ | ( | ||
+ | [emp_no] => 10001 | ||
+ | [birth_date] => 1953-09-02 | ||
+ | [first_name] => Georgi | ||
+ | [last_name] => Facello | ||
+ | [gender] => M | ||
+ | [hire_date] => 1986-06-26 | ||
+ | ) | ||
+ | */ | ||
+ | |||
+ | $SQL = ' | ||
+ | $result = $db->Execute($SQL); | ||
+ | |||
+ | $updateArray = array(' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | $SQL = $db-> | ||
+ | |||
+ | print $SQL | ||
+ | /* | ||
+ | * returns: UPDATE employees | ||
+ | SET FIRST_NAME=' | ||
+ | LAST_NAME=' | ||
+ | WHERE emp_no=10001 | ||
+ | */ | ||
</ | </ | ||
+ | Note: | ||
+ | * The '' | ||
+ | * Because the value of the '' | ||
+ | If we want the returned statement to include all the supplied fields, we add the '' | ||
- | ==== $fieldArray | + | <code php> |
+ | $SQL = $db-> | ||
+ | /* | ||
+ | * returns | ||
+ | * UPDATE employees SET FIRST_NAME=' | ||
+ | LAST_NAME=' | ||
+ | GENDER=' | ||
+ | WHERE emp_no=10001 | ||
+ | */ | ||
+ | </ | ||
v5/reference/connection/getupdatesql.txt · Last modified: 2023/09/26 17:43 by dregad