/** * Returns an array with only those keys that are actually in the schema. * * @param array $Data An array of key/value pairs. * @return array The filtered array. */ public function FilterSchema($Data) { $Fields = $this->Schema->Fields($this->Name); $Result = array_intersect_key($Data, $Fields); return $Result; }
/** * @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) { $QuotedFields[$this->SQL->QuoteIdentifier(trim($Name, '`'))] = $Value; } $Result = $this->SQL->Put($this->Name, $QuotedFields, $Where, $Limit); } return $Result; }