3 namespace RedUNIT\Sqlite;
5 use RedUNIT\Sqlite as Sqlite;
6 use RedBeanPHP\Facade as R;
11 * Tests the parameter binding functionality in RedBeanPHP.
12 * These test scenarios include for instance: NULL handling,
13 * binding parameters in LIMIT clauses and so on.
15 * @file RedUNIT/Sqlite/Parambind.php
16 * @desc Tests\PDO parameter binding.
17 * @author Gabor de Mooij and the RedBeanPHP Community
18 * @license New BSD/GPLv2
20 * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
21 * This source file is subject to the New BSD/GPLv2 License that is bundled
22 * with this source code in the file license.txt.
24 class Parambind extends Sqlite
27 * Test parameter binding with SQLite.
31 public function testParamBindWithSQLite()
33 $toolbox = R::getToolBox();
34 $adapter = $toolbox->getDatabaseAdapter();
35 $writer = $toolbox->getWriter();
36 $redbean = $toolbox->getRedBean();
37 $pdo = $adapter->getDatabase();
38 asrt( (int) $adapter->getCell( "SELECT 123" ), 123 );
39 asrt( (int) $adapter->getCell( "SELECT ?", array( "987" ) ), 987 );
40 asrt( (int) $adapter->getCell( "SELECT ?+?", array( "987", "2" ) ), 989 );
41 asrt( (int) $adapter->getCell(
42 "SELECT :numberOne+:numberTwo",
49 $pair = $adapter->getAssoc( "SELECT 'thekey','thevalue' " );
50 asrt( is_array( $pair ), TRUE );
51 asrt( count( $pair ), 1 );
52 asrt( isset( $pair["thekey"] ), TRUE );
53 asrt( $pair["thekey"], "thevalue" );
54 testpack( 'Test whether we can properly bind and receive NULL values' );
55 asrt( $adapter->getCell( 'SELECT :nil ', array( ':nil' => 'NULL' ) ), 'NULL' );
56 asrt( $adapter->getCell( 'SELECT :nil ', array( ':nil' => NULL ) ), NULL );
57 asrt( $adapter->getCell( 'SELECT ? ', array( 'NULL' ) ), 'NULL' );
58 asrt( $adapter->getCell( 'SELECT ? ', array( NULL ) ), NULL );