/** * As well as setting connection this also populates the other variables * of this class from data in the connection object * * @param Doctrine_Connection_Mysql $connection * @return self */ public function setConnection(Doctrine_Connection_Mysql $connection) { $this->_connection = $connection; $dsnParts = $this->_parseDsn($connection->getOption('dsn')); $this->setUsername($connection->getOption('username'))->setPassword($connection->getOption('password'))->setHost($dsnParts['host'])->setPort($dsnParts['port'])->setDbName($dsnParts['dbname']); return $this; }
public function quoteIdentifier($str, $checkOption = true) { // non-identifiers // (See http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html) if ('id' === $str || 'created_at' === $str || 'updated_at' === $str || 'lft' === $str || 'rgt' === $str || 'tree_key' === $str || 'level' === $str || 'public_flag' === $str || 'is_active' === $str || 'body' === $str || 'title' === $str || 'name' === $str || 'value' === $str || 1 === strlen($str) || strpos($str, '__') || strpos($str, '_id')) { return $str; } return parent::quoteIdentifier($str, $checkOption); }
public function __get($name) { if ($name === 'expression') { static $expressionModule = null; if ($expressionModule === null) { $class = 'Doctrine_Expression_' . $this->getDriverName() . '_ExtraFunctions'; $expressionModule = new $class($this); } return $expressionModule; } return parent::__get($name); }
/** * * @param Doctrine_Connection_Mysql $connection * @param string $backupPath The path to the sql file * to restore * @return void */ protected function restoreBackup(Doctrine_Connection_Mysql $connection, $backupPath) { if (!file_exists($backupPath)) { throw new Exception('Backup to restore database doesn\'t exist'); } $connection->dropDatabase(); $connection->createDatabase(); $importer = new sfDoctrineMysqlSafeMigrateMysqlCliImport($connection, sfConfig::get('app_sfDoctrineMysqlSafeMigratePlugin_mysql_path'), sfConfig::get('app_sfDoctrineMysqlSafeMigratePlugin_mysql_arguments')); try { $importer->importFrom($backupPath); } catch (Exception $e) { throw $e; } }