You are here: Re: Tricky Error « PHP Programming Language « IT news, forums, messages
Re: Tricky Error

Posted by Mladen Gogala on 05/12/05 06:51

On Wed, 11 May 2005 15:03:53 -0700, BKDotCom wrote:

>
> Could you elaborate on "bind variables"?
> what is this technique, or construct, or whatever you speak of?

Below is an example, taken from a little tool for administration of
oracle databases. The bind variable is ":FNO", in the WHERE clause
of the SQL statement in the $INFO variable. In the "execute" part there is
additional argument array("FNO"=>$FNO) which "binds" SQL placeholder FNO
to PHP variable $FNO. That is know as using bind variables. As my database
of choice is Oracle, I'll point you to an article written by an oracle guy:

http://www.rittman.net/archives/000832.html


Bind variables were originally invented by IBM in their DL/I database
and have made their way in to SQL92 standard. That means that pretty much
any database can do bind. MySQL and PostgresSQL can both do that, at least
if used through ADOdb modules. For more about bind variables, consult your
database product manuals.



<html>
<head>
<title>Resize File</title>
</head>
<body bgcolor="#EFECC7">
<center>
<h2>Resize File</h2>
<br>
<hr>
<?php
require_once ('helper.inc.php');
require_once "HTML/Form.php";
require ('csr2html.php');
session_start();
$DSN = $_SESSION['DSN'];
$db = NewADOConnection("oci8");
if (!empty($_GET['type'])) {
$TYPE = $_GET['type'];
$FNO = $_GET['file'];
} elseif (!empty($_POST['type'])) {
$TYPE = $_POST['type'];
$FNO = $_POST['file'];
$SIZE = $_POST['size'];
} else die("File was called incorrectly!<br>");
try {
$db->Connect($DSN['database'], $DSN['username'], $DSN['password']);
$INFO = "select file_name,ceil(bytes/1048576) as MB
from dba_".$TYPE."_files
where file_id=:FNO";
$rs = $db->Execute($INFO, array('FNO'=>$FNO));
$row = $rs->FetchRow();
if (!empty($_GET['file'])) {
$form = new HTML_Form($_SERVER['PHP_SELF'], "POST");
$form->addBlank(3);
$form->addHidden('file', $FNO);
$form->addHidden('type', $TYPE);
$form->addText('size', $row[0].':', $row[1].'M');
$form->addSubmit("submit", "Resize");
$form->display();
} elseif (!empty($SIZE)) {
$RSZ = "alter database $TYPE"."file $FNO resize $SIZE";
$db->Execute($RSZ);
$db->close();
$INVOKER = $_SESSION['invoker'];
header("location: $INVOKER");
}
}
catch(Exception $e) {
die($e->getTraceAsString());
}
?>
<hr>
</center>
</body>
</html>


--
Demagogue: One who preaches a doctrine he knows to be untrue to
men he knows to be idiots.
H.L. Mencken

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация