3 namespace RedUNIT\Postgres;
5 use RedUNIT\Postgres as Postgres;
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/Postgres/Parambind.php
16 * @desc Tests\PDO parameter binding for Postgres.
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 Postgres
27 * Test parameter binding.
31 public function testParamBindingWithPostgres()
33 testpack( "param binding pgsql" );
34 $page = R::dispense( "page" );
38 R::exec( "insert into page (name) values(:name) ", array( ":name" => "my name" ) );
39 R::exec( "insert into page (number) values(:one) ", array( ":one" => 1 ) );
40 R::exec( "insert into page (number) values(:one) ", array( ":one" => "1" ) );
41 R::exec( "insert into page (number) values(:one) ", array( ":one" => "1234" ) );
42 R::exec( "insert into page (number) values(:one) ", array( ":one" => "-21" ) );
44 testpack( 'Test whether we can properly bind and receive NULL values' );
45 $adapter = R::getDatabaseAdapter();
46 asrt( $adapter->getCell( 'SELECT TEXT( :nil ) ', array( ':nil' => 'NULL' ) ), 'NULL' );
47 asrt( $adapter->getCell( 'SELECT TEXT( :nil ) ', array( ':nil' => NULL ) ), NULL );
48 asrt( $adapter->getCell( 'SELECT TEXT( ? ) ', array( 'NULL' ) ), 'NULL' );
49 asrt( $adapter->getCell( 'SELECT TEXT( ? ) ', array( NULL ) ), NULL );