/** * Deletes a model * * @param Atomik_Model $model * @return bool */ public function delete(Atomik_Model $model) { if ($model->isNew()) { return false; } $builder = $model->getBuilder(); $this->_notify($builder, 'BeforeDelete', array($model)); $where = array($builder->getPrimaryKeyField()->name => $model->getPrimaryKey()); if ($this->_dbInstance->delete($builder->tableName, $where) === false) { $this->_notify($builder, 'FailDelete', array($model)); return false; } $this->_notify($builder, 'AfterDelete', array($model)); return true; }
/** * Sets whether queries should always be cached * * @param string $enable */ public static function setAlwaysCacheQueries($enable = true) { self::$_alwaysCacheQuery = $enable; }
public function __construct(Atomik_Db_Instance $instance) { $this->_instance = $instance; $this->_generator = $instance->getAdapter()->getDefinitionGenerator(); }
/** * Executes the sql against the specified db instance * * @param Atomik_Db_Instance $db * @return bool success */ public function run(Atomik_Db_Instance $db) { foreach ($this->_scripts as $script) { $this->_outputHandler->executingScript($script); $sql = $script->getSql(); try { $stmt = $db->prepare($sql); if (!$stmt->execute()) { $errorInfo = $stmt->errorInfo(); $this->_outputHandler->error($errorInfo[2]); return false; } } catch (Exception $e) { $this->_outputHandler->error($e->getMessage()); return false; } } return true; }
/** * Returns the prefixed table name * * @param string $tableName * @return string */ protected function _formatTableName($tableName) { return $this->_instance->getTablePrefix() . $tableName; }