Tricky Error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mladen Gogala

    #16
    Re: Tricky Error

    On Wed, 11 May 2005 15:03:53 -0700, BKDotCom wrote:
    [color=blue]
    >
    > Could you elaborate on "bind variables"?
    > what is this technique, or construct, or whatever you speak of?[/color]

    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"=>$F NO) 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:




    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="#EFECC 7">
    <center>
    <h2>Resize File</h2>
    <br>
    <hr>
    <?php
    require_once ('helper.inc.ph p');
    require_once "HTML/Form.php";
    require ('csr2html.php' );
    session_start() ;
    $DSN = $_SESSION['DSN'];
    $db = NewADOConnectio n("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."_f iles
    where file_id=:FNO";
    $rs = $db->Execute($INF O, array('FNO'=>$F NO));
    $row = $rs->FetchRow();
    if (!empty($_GET['file'])) {
    $form = new HTML_Form($_SER VER['PHP_SELF'], "POST");
    $form->addBlank(3);
    $form->addHidden('fil e', $FNO);
    $form->addHidden('typ e', $TYPE);
    $form->addText('size' , $row[0].':', $row[1].'M');
    $form->addSubmit("sub mit", "Resize");
    $form->display();
    } elseif (!empty($SIZE)) {
    $RSZ = "alter database $TYPE"."file $FNO resize $SIZE";
    $db->Execute($RSZ );
    $db->close();
    $INVOKER = $_SESSION['invoker'];
    header("locatio n: $INVOKER");
    }
    }
    catch(Exception $e) {
    die($e->getTraceAsStri ng());
    }
    ?>
    <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

    Comment

    Working...