File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / oci8 / tests / error_bind.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:58 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
Test some oci_bind_by_name error conditions
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php

require(dirname(__FILE__).'/connect.inc');

$drop = "drop table bind_test";
$statement = oci_parse($c, $drop);
@oci_execute($statement);

$create = "create table bind_test(name varchar(10))";
$statement = oci_parse($c, $create);
oci_execute($statement);


echo "Insert value\n";

$name = 'abc';
$stmt = oci_parse($c, "insert into bind_test values (:name)");
oci_bind_by_name($stmt, ":name", $name, 10, SQLT_CHR);
var_dump(oci_execute($stmt));

echo "Test 1 - Assign a resource to the bind variable and execute \n";
$name=$c;
var_dump(oci_execute($stmt));

echo "Test 2 - Re-bind a resource\n";
oci_bind_by_name($stmt, ":name", $c);
var_dump(oci_execute($stmt));
var_dump($c);

// Use a connection resource instead of a ROWID.
echo "Test 3 - Resource mismatch !!\n";
$stmt = oci_parse($c, "update bind_test set name='xyz' returning rowid into :r_id");
oci_bind_by_name($stmt, ":r_id", $c);
var_dump(oci_execute($stmt));

// Clean up

$drop = "drop table bind_test";
$statement = oci_parse($c, $drop);
@oci_execute($statement);

echo "Done\n";

?>
--EXPECTF--
Insert value
bool(true)
Test 1 - Assign a resource to the bind variable and execute 

Warning: oci_execute(): Invalid variable used for bind in %s on line %d
bool(false)
Test 2 - Re-bind a resource

Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d

Warning: oci_execute(): Invalid variable used for bind in %s on line %d
bool(false)
resource(%d) of type (oci8 connection)
Test 3 - Resource mismatch !!

Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d

Warning: oci_execute(): ORA-%r(01008|57000)%r: %s on line %d
bool(false)
Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>