コード例 #1
0
ファイル: SelectExecutor.php プロジェクト: addiks/phpsql
 /**
  * Finds all usable indexes for given conditions (if any) and table.
  *
  * @param  ConditionJob[] $conditions
  * @param  TableSchema    $tableSchema
  * @param  string         $tableName
  * @param  string         $schemaId
  * @return IndexInterface[]
  */
 protected function findIndexesForTableConditions(array $conditions, TableInterface $table, $tableName)
 {
     $indexes = array();
     /* @var $tableSchema TableSchema */
     $tableSchema = $table->getTableSchema();
     $conditionColumns = array();
     foreach ($conditions as $condition) {
         /* @var $condition ConditionJob */
         $column = $condition->getFirstParameter();
         $fixedValue = $condition->getLastParameter();
         if ($fixedValue instanceof ColumnSpecifier) {
             list($column, $fixedValue) = [$fixedValue, $column];
         }
         if ($column instanceof ColumnSpecifier) {
             /* @var $column ColumnSpecifier */
             if (is_null($column->getTable()) || $column->getTable() === $tableName) {
                 $columnId = $tableSchema->getColumnIndex($column->getColumn());
                 if (is_int($columnId) && $columnId >= 0) {
                     $conditionColumns[$column->getColumn()] = $columnId;
                 }
             }
         }
     }
     if (!empty($conditionColumns)) {
         foreach ($tableSchema->getIndexIterator() as $indexId => $indexSchema) {
             /* @var $indexSchema IndexSchema */
             $indexColumns = $indexSchema->getColumns();
             if (empty(array_diff($indexColumns, $conditionColumns))) {
                 /* @var $index IndexInterface */
                 $index = $table->getIndex($indexId);
                 $indexes[] = $index;
             }
         }
     }
     return $indexes;
 }
コード例 #2
0
ファイル: TableFactory.php プロジェクト: addiks/phpsql
 public function modifyColumnOnTable($schemaId, $tableId, $columnId, TableInterface $table, ColumnSchema $columnSchema)
 {
     /* @var $columnData ColumnDataInterface */
     $columnData = $this->columnDataFactory->createColumnData($schemaId, $tableId, $columnId, $columnSchema);
     $table->modifyColumn($columnSchema, $columnData);
 }