Actions

API16

Difference between revisions of "JDatabaseMySQL/updateObject"

From Joomla! Documentation

< API16:JDatabaseMySQL
m (removing red link to edit, no existant pages)
 
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JDatabaseMySQL/updateObject|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JDatabaseMySQL/updateObject}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 74: Line 74:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JDatabaseMySQL/updateObject|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JDatabaseMySQL/updateObject}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 89: Line 89:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Latest revision as of 22:01, 12 May 2013

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Description

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

updateObject($table, &$object, $keyName, $updateNulls=true)
Parameter Name Default Value Description
$table $updateNulls
&$object
$keyName
$updateNulls true

Defined in

libraries/joomla/database/database/mysql.php

Importing

jimport( 'joomla.database.database.mysql' );

Source Body

public function updateObject($table, &$object, $keyName, $updateNulls=true)
{
        $fmtsql = 'UPDATE '.$this->nameQuote($table).' SET %s WHERE %s';
        $tmp = array();
 
        foreach (get_object_vars($object) as $k => $v) {
                if (is_array($v) or is_object($v) or $k[0] == '_') { // internal or NA field
                        continue;
                }
 
                if ($k == $keyName) {
                        // PK not to be updated
                        $where = $keyName . '=' . $this->Quote($v);
                        continue;
                }
 
                if ($v === null) {
                        if ($updateNulls) {
                                $val = 'NULL';
                        } else {
                                continue;
                        }
                } else {
                        $val = $this->isQuoted($k) ? $this->Quote($v) : (int) $v;
                }
                $tmp[] = $this->nameQuote($k) . '=' . $val;
        }
        $this->setQuery(sprintf($fmtsql, implode(",", $tmp) , $where));
        return $this->query();
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />