Example #1
0
 /**
  * Inserts a new record into the database.
  *
  * @access  protected
  * @param   \mako\database\midgard\Query  $query  Query builder
  */
 protected function insertRecord($query)
 {
     if ($this->primaryKeyType === static::PRIMARY_KEY_TYPE_INCREMENTING) {
         $this->columns[$this->primaryKey] = $query->insertAndGetId($this->columns, $this->primaryKey);
     } else {
         switch ($this->primaryKeyType) {
             case static::PRIMARY_KEY_TYPE_UUID:
                 $this->columns[$this->primaryKey] = UUID::v4();
                 break;
             case static::PRIMARY_KEY_TYPE_CUSTOM:
                 $this->columns[$this->primaryKey] = $this->generatePrimaryKey();
                 break;
         }
         $query->insert($this->columns);
     }
 }