/**
  * 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;
 }
コード例 #2
0
 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);
 }
コード例 #3
0
ファイル: ExtraFunctions.php プロジェクト: te-koyama/openpne
 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;
     }
 }