Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement SQLite3Stmt::getSQL method, returning the original statemen…
…t SQL, eventually expanded
- Loading branch information
BohwaZ
committed
Dec 7, 2018
1 parent
abd9f08
commit 9247df1
Showing
3 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--TEST-- | ||
SQLite3Stmt::getSQL test | ||
--SKIPIF-- | ||
<?php require_once(__DIR__ . '/skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once(__DIR__ . '/new_db.inc'); | ||
|
||
$db->enableExceptions(true); | ||
|
||
$stmt = $db->prepare('SELECT :a, :b, ?;'); | ||
|
||
$stmt->bindValue(':a', 42); | ||
$stmt->bindValue(':b', 'php'); | ||
$stmt->bindValue(3, 43); | ||
|
||
echo "Getting non-expanded SQL statement\n"; | ||
var_dump($stmt->getSQL(false)); | ||
|
||
echo "Execute statement\n"; | ||
var_dump($res = $stmt->execute()); | ||
|
||
echo "Statement result\n"; | ||
var_dump($res->fetchArray(SQLITE3_NUM)); | ||
|
||
echo "Closing DB\n"; | ||
var_dump($db->close()); | ||
|
||
echo "Done\n"; | ||
?> | ||
--EXPECTF-- | ||
Getting non-expanded SQL statement | ||
string(17) "SELECT :a, :b, ?;" | ||
Execute statement | ||
object(SQLite3Result)#3 (0) { | ||
} | ||
Statement result | ||
array(3) { | ||
[0]=> | ||
int(42) | ||
[1]=> | ||
string(3) "php" | ||
[2]=> | ||
int(43) | ||
} | ||
Closing DB | ||
bool(true) | ||
Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--TEST-- | ||
SQLite3Stmt::getSQL expanded test | ||
--SKIPIF-- | ||
<?php require_once(__DIR__ . '/skipif.inc'); | ||
|
||
if (SQLite3::version()['versionNumber'] < 3014000) { | ||
die('skip SQLite < 3.14 installed, requires SQLite >= 3.14'); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once(__DIR__ . '/new_db.inc'); | ||
|
||
$db->enableExceptions(true); | ||
|
||
$stmt = $db->prepare('SELECT :a, :b, ?;'); | ||
|
||
$stmt->bindValue(':a', 42); | ||
$stmt->bindValue(':b', 'php'); | ||
$stmt->bindValue(3, 43); | ||
|
||
echo "Getting expanded SQL statement\n"; | ||
var_dump($stmt->getSQL(true)); | ||
|
||
echo "Execute statement\n"; | ||
var_dump($res = $stmt->execute()); | ||
|
||
echo "Statement result\n"; | ||
var_dump($res->fetchArray(SQLITE3_NUM)); | ||
|
||
$stmt->reset(); | ||
|
||
echo "Change binded values\n"; | ||
$stmt->bindValue(':a', 'TEST'); | ||
$stmt->bindValue(':b', '!!!'); | ||
$stmt->bindValue(3, 40); | ||
|
||
echo "Getting expanded SQL statement\n"; | ||
var_dump($stmt->getSQL(true)); | ||
|
||
echo "Closing DB\n"; | ||
var_dump($db->close()); | ||
|
||
echo "Done\n"; | ||
?> | ||
--EXPECTF-- | ||
Getting expanded SQL statement | ||
string(21) "SELECT 42, 'php', 43;" | ||
Execute statement | ||
object(SQLite3Result)#3 (0) { | ||
} | ||
Statement result | ||
array(3) { | ||
[0]=> | ||
int(42) | ||
[1]=> | ||
string(3) "php" | ||
[2]=> | ||
int(43) | ||
} | ||
Change binded values | ||
Getting expanded SQL statement | ||
string(25) "SELECT 'TEST', '!!!', 40;" | ||
Closing DB | ||
bool(true) | ||
Done |