yii\sphinx\Schema::findColumns PHP Method

findColumns() protected method

Collects the metadata of index columns.
protected findColumns ( IndexSchema $index ) : boolean
$index IndexSchema the index metadata
return boolean whether the index exists in the database
    protected function findColumns($index)
    {
        $sql = 'DESCRIBE ' . $this->quoteSimpleIndexName($index->name);
        try {
            $columns = $this->db->createCommand($sql)->queryAll();
        } catch (\Exception $e) {
            $previous = $e->getPrevious();
            if ($previous instanceof \PDOException && strpos($previous->getMessage(), 'SQLSTATE[42S02') !== false) {
                // index does not exist
                // https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html#error_er_bad_table_error
                return false;
            }
            throw $e;
        }
        if (empty($columns[0]['Agent'])) {
            foreach ($columns as $info) {
                $column = $this->loadColumnSchema($info);
                $index->columns[$column->name] = $column;
                if ($column->isPrimaryKey) {
                    $index->primaryKey = $column->name;
                }
            }
            return true;
        }
        // Distributed index :
        foreach ($columns as $column) {
            if (!empty($column['Type']) && strcasecmp('local', $column['Type']) !== 0) {
                // skip type 'agent'
                continue;
            }
            $agent = $this->getIndexSchema($column['Agent']);
            if ($agent !== null) {
                $index->columns = $agent->columns;
                $index->primaryKey = $agent->primaryKey;
                return true;
            }
        }
        $this->applyDefaultColumns($index);
        return true;
    }