User Tools

Site Tools


kurs:php_bind_param
<?php
require_once('db_login.php');

$first_name = 'Ellen';
$last_name  = 'Abel';

$sql = sprintf("select * from employees where first_name='%s' and last_name='%s'",
       $first_name, $last_name);

print $sql;
	   
$q = oci_parse($db, $sql);

$r = oci_execute($q, OCI_DEFAULT);

$row = oci_fetch_array($q,OCI_ASSOC);
print "<pre>\n";
print_r($row);
print_r($_REQUEST);
print "</pre>\n";

// mit bind param

$sql = "select * from employees where first_name=:first_name and last_name=:last_name";
$q = oci_parse($db, $sql);

oci_bind_by_name($q, ":first_name", $first_name, 32 );
oci_bind_by_name($q, ":last_name",  $last_name, 32 );

$r = oci_execute($q, OCI_DEFAULT);

$row = oci_fetch_array($q,OCI_ASSOC);
print "<pre>\n";
print_r($row);
print_r($_REQUEST);
print "</pre>\n";

$first_name = 'Pat';
$last_name  = 'Fay';

oci_bind_by_name($q, ":first_name", $first_name, 32 );
oci_bind_by_name($q, ":last_name",  $last_name, 32 );

$r = oci_execute($q, OCI_DEFAULT);

$row = oci_fetch_array($q,OCI_ASSOC);
print "<pre>\n";
print_r($row);
print_r($_REQUEST);
print "</pre>\n";


oci_close($db);
?>
kurs/php_bind_param.txt · Last modified: 2014/09/10 21:22 (external edit)