/** * Crear registro * * @param array $data * @return boolean * @throw PDOException */ public function create(array $data = array()) { $this->dump($data); // Callback antes de crear if ($this->callback('_beforeCreate') === false) { return false; } $sql = QueryGenerator::insert($this, $data); if (!self::prepare($sql)->execute($data)) { return false; } // Verifica si la PK es autogenerada $pk = static::getPK(); if (!isset($this->{$pk})) { $this->{$pk} = QueryGenerator::query(static::getDriver(), 'last_insert_id', self::dbh(), $pk, static::getTable(), static::getSchema()); } // Callback despues de crear $this->callback('_afterCreate'); return true; }