コード例 #1
0
ファイル: Cubrid.php プロジェクト: redcatphp/datamap
 function debug($level = self::DEBUG_ON)
 {
     parent::debug($level);
     if ($this->debugLevel & self::DEBUG_EXPLAIN && $this->isConnected) {
         $this->pdo->exec('SET TRACE ON');
     }
 }
コード例 #2
0
ファイル: Cubrid.php プロジェクト: kidaa30/redcat
 function debug($enable = true, $loggingResult = true, $loggingExplain = true)
 {
     parent::debug($enable = true, $loggingResult = true, $loggingExplain = true);
     if ($this->loggingExplain && $this->isConnected) {
         $this->pdo->exec('SET TRACE ON');
     }
 }
コード例 #3
0
ファイル: Mysql.php プロジェクト: redcatphp/datamap
 function connect()
 {
     if ($this->isConnected) {
         return;
     }
     parent::connect();
     $serverVersion = $this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
     $this->isMariaDB = strpos($serverVersion, 'MariaDB') !== false;
     if ($this->isMariaDB) {
         $this->version = substr($serverVersion, 0, strpos($serverVersion, '-'));
     } else {
         $this->version = floatval($serverVersion);
     }
     if (!$this->isMariaDB && $this->version >= 5.5) {
         $this->encoding = 'utf8mb4';
     }
     $this->pdo->setAttribute(\PDO::MYSQL_ATTR_INIT_COMMAND, 'SET NAMES ' . $this->encoding);
     //on every re-connect
     $this->pdo->exec('SET NAMES ' . $this->encoding);
     //also for current connection
 }
コード例 #4
0
ファイル: Sqlite.php プロジェクト: kidaa30/redcat
 function createQuery($type, $properties, $primaryKey = 'id', $uniqTextKey = 'uniq', $cast = [], $func = [])
 {
     if (!$this->foreignKeyEnabled) {
         $this->enableForeignKeys();
     }
     return parent::createQuery($type, $properties, $primaryKey, $uniqTextKey, $cast, $func);
 }
コード例 #5
0
ファイル: SQL.php プロジェクト: redcatphp/datamap
 function joinCascade($map = [])
 {
     $q = $this;
     $db = $this->dataSource;
     foreach ($map as $table => $on) {
         $parent = array_shift($on);
         if (substr($table, 0, 4) == 'via:') {
             $table = substr($table, 4);
             $inversion = true;
         } else {
             $inversion = false;
         }
         $tableEsc = $this->esc($table);
         $tablePk = $db[$table]->getPrimaryKey();
         $tablePkEsc = $this->esc($tablePk);
         $parentEsc = $this->esc($parent);
         $parentPk = $db[$parent]->getPrimaryKey();
         $parentPkEsc = $this->esc($parentPk);
         $parentCol = $parent . '_' . $parentPk;
         $parentColEsc = $this->esc($parentCol);
         $tableCol = $table . '_' . $tablePk;
         $tableColEsc = $this->esc($tableCol);
         if ($inversion) {
             $join = "{$tableEsc} ON {$tableEsc}.{$parentColEsc} = {$parentEsc}.{$parentPkEsc}";
         } else {
             $join = "{$tableEsc} ON {$tableEsc}.{$tablePkEsc} = {$parentEsc}.{$tableColEsc}";
         }
         $params = [];
         foreach ($on as $extra) {
             if (DataSourceSQL::canBeTreatedAsInt($extra)) {
                 $params[] = $extra;
                 $extra = "{$tableEsc}.{$tablePkEsc} = ?";
             }
             if (is_array($extra)) {
                 $tmp = array_shift($extra);
                 $params[] = $extra;
                 $extra = $tmp;
             }
             $join .= " AND {$extra}";
         }
         $q = $q->join($join, $params);
     }
     return $q;
 }