示例#1
0
 /**
  * @param unknown_type $Fields
  * @param unknown_type $Where
  * @param unknown_type $Limit
  * @todo add doc
  */
 public function Update($Fields, $Where = FALSE, $Limit = FALSE)
 {
     $Result = FALSE;
     // primary key (always included in $Where when updating) might be "required"
     $AllFields = $Fields;
     if (is_array($Where)) {
         $AllFields = array_merge($Fields, $Where);
     }
     if ($this->Validate($AllFields)) {
         $this->AddUpdateFields($Fields);
         // Strip out fields that aren't in the schema.
         // This is done after validation to allow custom validations to work.
         $SchemaFields = $this->Schema->Fields();
         $Fields = array_intersect_key($Fields, $SchemaFields);
         // Quote all of the fields.
         $QuotedFields = array();
         foreach ($Fields as $Name => $Value) {
             if (is_array($Value) && in_array($Name, array('Attributes', 'Data'))) {
                 $Value = empty($Value) ? NULL : serialize($Value);
             }
             $QuotedFields[$this->SQL->QuoteIdentifier(trim($Name, '`'))] = $Value;
         }
         $Result = $this->SQL->Put($this->Name, $QuotedFields, $Where, $Limit);
     }
     return $Result;
 }