コード例 #1
0
ファイル: SqliteAdapter.php プロジェクト: bondarovich/Propel2
 public function initConnection(ConnectionInterface $con, array $settings)
 {
     $con->query('PRAGMA foreign_keys = ON');
     parent::initConnection($con, $settings);
     //add regex support
     $con->sqliteCreateFunction('regexp', function ($pattern, $value) {
         mb_regex_encoding('UTF-8');
         return false !== mb_ereg($pattern, $value) ? 1 : 0;
     });
 }
コード例 #2
0
 /**
  * We need to replace oracle: to oci: in connection's dsn.
  *
  * @param array $params
  * @return array
  */
 protected function prepareParams($params)
 {
     if (isset($params['dsn'])) {
         $params['dsn'] = str_replace('oracle:', 'oci:', $params['dsn']);
     }
     return parent::prepareParams($params);
 }
コード例 #3
0
 /**
  * Prepare the parameters for a PDO connection.
  * Protects MySQL from charset injection risk.
  * @see http://www.propelorm.org/ticket/1360
  *
  * @param array $params the connection parameters from the configuration
  *
  * @return array the modified parameters
  */
 protected function prepareParams($params)
 {
     if (isset($params['settings']['charset'])) {
         if (false === strpos($params['dsn'], ';charset=')) {
             $params['dsn'] .= ';charset=' . $params['settings']['charset'];
             unset($params['settings']['charset']);
         }
     }
     return parent::prepareParams($params);
 }
コード例 #4
0
ファイル: MysqlAdapter.php プロジェクト: rozwell/Propel2
    /**
     * Prepare the parameters for a PDO connection.
     * Protects MySQL from charset injection risk.
     * @see   http://www.propelorm.org/ticket/1360
     *
     * @param array the connection parameters from the configuration
     *
     * @return array the modified parameters
     */
    protected function prepareParams($params)
    {
        if (isset($params['settings']['charset']['value'])) {
            if (version_compare(PHP_VERSION, '5.3.6', '<')) {
                throw new PropelException(<<<EXCEPTION
Connection option "charset" cannot be used for MySQL connections in PHP versions older than 5.3.6.
Please refer to http://www.propelorm.org/ticket/1360 for instructions and details about the implications of
using a SET NAMES statement in the "queries" setting.
EXCEPTION
);
            } else {
                if (strpos($params['dsn'], ';charset=') === false) {
                    $params['dsn'] .= ';charset=' . $params['settings']['charset']['value'];
                    unset($params['settings']['charset']);
                }
            }
        }
        return parent::prepareParams($params);
    }
コード例 #5
0
 public function initConnection(ConnectionInterface $con, array $settings)
 {
     $con->query('PRAGMA foreign_keys = ON');
     parent::initConnection($con, $settings);
 }