1--TEST-- 2PDO Common: assert that bindParam does not modify parameter 3--SKIPIF-- 4<?php # vim:ft=php 5if (!extension_loaded('pdo')) die('skip'); 6$dir = getenv('REDIR_TEST_DIR'); 7if (false == $dir) die('skip no driver'); 8require_once $dir . 'pdo_test.inc'; 9PDOTest::skip(); 10?> 11--FILE-- 12<?php 13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/'); 14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 15$db = PDOTest::factory(); 16 17switch ($db->getAttribute(PDO::ATTR_DRIVER_NAME)) { 18 case 'dblib': 19 // environment settings can influence how the table is created if specifics are missing 20 // https://msdn.microsoft.com/en-us/library/ms174979.aspx#Nullability Rules Within a Table Definition 21 $sql = 'create table test (id int, name varchar(10) null)'; 22 break; 23 default: 24 $sql = 'create table test (id int, name varchar(10))'; 25 break; 26} 27$db->exec($sql); 28 29$stmt = $db->prepare('insert into test (id, name) values(0, :name)'); 30$name = NULL; 31$before_bind = $name; 32$stmt->bindParam(':name', $name, PDO::PARAM_NULL); 33if ($name !== $before_bind) { 34 echo "bind: fail\n"; 35} else { 36 echo "bind: success\n"; 37} 38var_dump($stmt->execute()); 39var_dump($db->query('select name from test where id=0')->fetchColumn()); 40 41?> 42--EXPECT-- 43bind: success 44bool(true) 45NULL 46