I like to use prepared Statements on SQL-calls to a SQLITE3 Database, so i have to use "exectue()" on statements. Fetching results stucks on error "Fatal error: Uncaught Error: Call to a member function fetch() on bool".
try {
$SQL = "SELECT * FROM myTable";
// this works fine:
$result = $db->query($SQL)->fetch(SQLITE3_ASSOC);
print_r($result); // actually delivers 1 recordset
// this not:
$stmt = $db->prepare($SQL);
$result = $stmt->execute()->fetch(SQLITE3_ASSOC); // <= Error
print_r($result);
} catch (PDOException $e) {
$ret['error'] = $e->getMessage();
} catch (Exception $e) {
$ret['error'] = $e->getMessage();
}
die(json_encode($ret));
=> "Fatal error: Uncaught Error: Call to a member function fetch() on bool in..."
Same on fetchArray(). What's wrong with this code?