当前位置: 首页>>代码示例>>PHP>>正文


PHP Driver::buildSQL方法代码示例

本文整理汇总了PHP中Driver::buildSQL方法的典型用法代码示例。如果您正苦于以下问题:PHP Driver::buildSQL方法的具体用法?PHP Driver::buildSQL怎么用?PHP Driver::buildSQL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Driver的用法示例。


在下文中一共展示了Driver::buildSQL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * @param Driver $driver
  * @param Table $table
  * @param Query $query
  * @param bool $asArray
  */
 public function __construct(Driver $driver, Table $table, Query $query, $asArray = false)
 {
     $this->asArray = $asArray;
     $this->table = $table;
     $params = [];
     $this->tableName = $table->getName();
     if (!$this->asArray) {
         $this->recordClasses = [$this->tableName => $table->getDatabase()->getClassMapper()->getClassForRecord($this->tableName)];
     }
     $sql = $query->getRawSql();
     if ($sql === null) {
         $sql = $driver->buildSQL($table, $query, $params);
         $this->fetchStyle = \PDO::FETCH_NUM;
         foreach ($table->getColumns() as $column) {
             if ($column->isPrimaryKey()) {
                 $this->primaryKeyOrdinals[$this->tableName][$column->getOrdinal()] = true;
             }
             $this->columnOrdinalMap[$this->tableName][$column->getOrdinal()] = $column->getName();
         }
         $offset = count($table->getColumns());
         foreach ($query->getJoins() as $join) {
             if (isset($join['cardinality'])) {
                 $joinedTableName = $join['table'];
                 $joinedTable = $table->getDatabase()->getTable($joinedTableName);
                 $this->joinedTables[$joinedTableName] = $joinedTable;
                 if (!$this->asArray) {
                     $this->recordClasses[$joinedTableName] = $joinedTable->getDatabase()->getClassMapper()->getClassForRecord($joinedTableName);
                 }
                 foreach ($joinedTable->getColumns() as $column) {
                     if ($column->isPrimaryKey()) {
                         $this->primaryKeyOrdinals[$joinedTableName][$offset + $column->getOrdinal()] = true;
                     }
                     $this->columnOrdinalMap[$joinedTableName][$offset + $column->getOrdinal()] = $column->getName();
                 }
                 $this->cardinalities[$joinedTableName] = $join['cardinality'];
                 if ($join['cardinality'] === Query::CARDINALITY_ONE_TO_MANY) {
                     $this->properties[$joinedTableName] = $joinedTableName;
                 } else {
                     $this->properties[$joinedTableName] = array_keys($join['on']);
                 }
                 $offset += count($joinedTable->getColumns());
             }
         }
     } else {
         $this->fetchStyle = \PDO::FETCH_ASSOC;
         $this->rawSql = true;
     }
     $this->result = $driver->query($sql, $params);
     $this->fetchNextRow();
 }
开发者ID:jamend,项目名称:selective-orm,代码行数:56,代码来源:Hydrator.php


注:本文中的Driver::buildSQL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。