示例#1
0
文件: Base.php 项目: lerre/framework
 /**
  * Create object during save
  * 
  * @throws Mad_Model_Exception_Validation
  */
 protected function _saveCreate()
 {
     $this->_recordTimestamps();
     // build & execute SQL
     $sql = "INSERT INTO {$this->_tableName} (" . "    " . $this->getColumnStr() . ") VALUES (" . "    " . $this->getInsertValuesStr() . ")";
     $insertId = $this->connection->insert($sql, "{$this->_className} Insert");
     // only set the pk if it's not already set
     if ($this->primaryKey() && $this->{$this->primaryKey()} == null) {
         $this->_attributes[$this->primaryKey()] = $insertId;
     }
     return $insertId;
 }