Exemplo n.º 1
0
 /**
  * @param unknown_type $Fields
  * @return unknown
  * @todo add doc
  */
 public function Insert($Fields)
 {
     $Result = FALSE;
     $this->AddInsertFields($Fields);
     if ($this->Validate($Fields, TRUE)) {
         // 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);
             }
             // Make sure integers are not empty for MySQL strict mode.
             if (empty($Value) && stristr($SchemaFields[$Name]->Type, 'int') !== FALSE) {
                 $Value = 0;
             }
             $QuotedFields[$this->SQL->QuoteIdentifier(trim($Name, '`'))] = $Value;
         }
         $Result = $this->SQL->Insert($this->Name, $QuotedFields);
     }
     return $Result;
 }
Exemplo n.º 2
0
 /**
  * @param unknown_type $Fields
  * @return unknown
  * @todo add doc
  */
 public function Insert($Fields)
 {
     $Result = FALSE;
     $this->AddInsertFields($Fields);
     if ($this->Validate($Fields, TRUE)) {
         // 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->Insert($this->Name, $QuotedFields);
     }
     return $Result;
 }
Exemplo n.º 3
0
 /**
  * @param unknown_type $Fields
  * @return unknown
  * @todo add doc
  */
 public function Insert($Fields)
 {
     $Result = FALSE;
     if ($this->Validate($Fields, TRUE)) {
         $this->AddInsertFields($Fields);
         $Result = $this->SQL->Insert($this->Name, $Fields);
     }
     return $Result;
 }