Reputation: 4559
I use Sqlcipher in PHP. I want to select data from the encrypted database. I can select and decrypt data in command line by blow sqlite command:
$ sqlite3 test.db
sqlite> pragma key='secret';
Below php code execute perfectly with sqlit3 databse but not with sqlcipher encrypted database:
$con = new SQLite3('test.db');
$con->query("SELECT * FROM people;")->fetchArray();
How can I use pragma key='secret';
in SQL query in PHP?
Upvotes: 2
Views: 1847
Reputation: 4559
We need to build SQLCipher into the SQLite extension used within PHP.
$con = new SQLite3("test.db");
$con->exec("PRAGMA key = 'secret';");
$con->query("SELECT * FROM people;")->fetchArray();
Upvotes: 1