I’m trying to execute multiple SQL queries in a single request using PHP with the ADOdb library, and I’m having trouble getting the second query to run. Here’s the code I’m using to connect to an SQLite3 database:
require_once 'ADOdb/adodb.inc.php';
// Create a connection to the SQLite3 database
$db = NewADOConnection('sqlite3');
// Database path
$databasePath = 'test.db';
$db->Connect($databasePath);
// Trying to run multiple queries
$query = "PRAGMA table_info('test'); SELECT 1;";
$result = $db->Execute($query);
echo $result;
?>
What I’m trying to do:
I want to execute two SQL queries in a single execution: PRAGMA table_info(‘test’) and SELECT 1;.
The first query works, but the second query (SELECT 1;) does not return any result.
Problem:
When I run the above code, the first query (PRAGMA table_info(‘test’)) works fine and returns the table structure, but the second query (SELECT 1) doesn’t execute, and I don’t get any output for it.
I am not sure how to handle multiple queries in a single execution using ADOdb for SQLite3.
What I’ve tried:
I attempted running both queries in a single string, but only the first query seems to be executed.
I tried using separate calls for each query, but I still couldn’t figure out a way to make it work correctly.
Environment Details:
PHP version: [Add your PHP version here, e.g., PHP 7.4]
ADOdb version: [Add the version you’re using, e.g., ADOdb 5.20]
Database: SQLite3
What I’ve tried:
I’ve attempted running both queries in a single string as shown above, but only the first query (PRAGMA table_info(‘test’)) seems to work, and the second query (SELECT 1) is ignored.
I also tried running the queries separately but still encountered the issue.
Desired Result:
I expect the following results:
The first query (PRAGMA table_info(‘test’)) should output the table structure of the test table.
The second query (SELECT 1) should output the number 1.
Environment Details:
PHP version: [Your PHP version, e.g., PHP 7.4]
ADOdb version: [Your ADOdb version, e.g., ADOdb 5.20]
Database: SQLite3