I'm trying to show the indexes on a table using sqlite and PHP.
The manual here ( https://www.sqlite.org/cli.html ) suggests:
.indexes ?TABLE?
However, using
$pdo->query('.indexes my_table');
Shows:
PDOException: SQLSTATE[HY000]: General error: 1 near ".": syntax error
Is it possible to execute these dot commands using PHP and PDO?
edit: example code:
$this->pdo->query('DROP TABLE IF EXISTS test');
$this->pdo->query('CREATE TABLE test (id INT PRIMARY KEY NOT NULL, col1 text NOT NULL, col2 text NOT NULL)');
$this->pdo->query('CREATE INDEX col1 ON test (col1)');
$result = $this->pdo->query('PRAGMA table_info(test);')->fetchAll(\PDO::FETCH_OBJ);
print_r($result);
This does not show the indexes. The following errors:
$this->pdo->query('DROP TABLE IF EXISTS test');
$this->pdo->query('CREATE TABLE test (id INT PRIMARY KEY NOT NULL, col1 text NOT NULL, col2 text NOT NULL)');
$this->pdo->query('CREATE INDEX col1 ON test (col1)');
$result = $this->pdo->query('.indexes test')->fetchAll(\PDO::FETCH_OBJ);
print_r($result);
This returns an empty array:
$this->pdo->query('DROP TABLE IF EXISTS test');
$this->pdo->query('CREATE TABLE test (id INT PRIMARY KEY NOT NULL, col1 text NOT NULL, col2 text NOT NULL)');
$this->pdo->query('CREATE INDEX index_col1 ON test (col1)');
$result = $this->pdo->query('PRAGMA index_info(test);')->fetchAll(\PDO::FETCH_OBJ);
print_r($result);