当前位置: 首页>>代码示例>>PHP>>正文


PHP OCIBindByName函数代码示例

本文整理汇总了PHP中OCIBindByName函数的典型用法代码示例。如果您正苦于以下问题:PHP OCIBindByName函数的具体用法?PHP OCIBindByName怎么用?PHP OCIBindByName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了OCIBindByName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: uploadImageData

 function uploadImageData($db, $file, $currentPictureId, $table, $id)
 {
     // insert the new record into the media's table and load the
     // corresponding blob with the media's data
     // (we use oracle's pseudo column rowid which identifies a row
     // within a table (but not within a database) to refer to the
     // right record later on)
     $sql = "DECLARE\n                        obj ORDSYS.ORDImage;\n                        iblob BLOB;\n                BEGIN\n                        SELECT image INTO obj FROM {$table}\n                        WHERE {$id} = {$currentPictureId} FOR UPDATE;\n\n                        iblob := obj.source.localData;\n                        :extblob := iblob;\n\n                        UPDATE {$table} SET image = obj WHERE {$id} = {$currentPictureId};\n                END;";
     // the function OCINewDescriptor allocates storage to hold descriptors or
     // lob locators.
     // see http://www.php.net/manual/en/function.ocinewdescriptor.php
     $blob = OCINewDescriptor($db, OCI_D_LOB);
     $sql = strtr($sql, chr(13) . chr(10), " ");
     $stmt = OCIParse($db, $sql);
     // the function OCIBindByName binds a PHP variable to a oracle placeholder
     // (whether the variable will be used for input or output will be determined
     // run-time, and the necessary storage space will be allocated)
     // see http://www.php.net/manual/en/function.ocibindbyname.php
     OCIBindByName($stmt, ':extblob', $blob, -1, OCI_B_BLOB);
     echo "{$this->log} - {$sql} <br />";
     OCIExecute($stmt, OCI_DEFAULT);
     // read the files data and load it into the blob
     $blob->savefile($file);
     OCIFreeStatement($stmt);
     $blob->free();
 }
开发者ID:GeorgesAlkhouri,项目名称:openmuseum,代码行数:26,代码来源:DbImageUploader.php

示例2: executeBoundSQL

function executeBoundSQL($cmdstr, $list)
{
    /* Sometimes a same statement will be excuted for severl times, only
    	 the value of variables need to be changed.
    	 In this case you don't need to create the statement several times; 
    	 using bind variables can make the statement be shared and just 
    	 parsed once. This is also very useful in protecting against SQL injection. See example code below for       how this functions is used */
    global $db_conn, $success;
    $statement = OCIParse($db_conn, $cmdstr);
    if (!$statement) {
        echo "<br>Cannot parse the following command: " . $cmdstr . "<br>";
        $e = OCI_Error($db_conn);
        echo htmlentities($e['message']);
        $success = False;
    }
    foreach ($list as $tuple) {
        foreach ($tuple as $bind => $val) {
            //echo $val;
            //echo "<br>".$bind."<br>";
            OCIBindByName($statement, $bind, $val);
            unset($val);
            //make sure you do not remove this. Otherwise $val will remain in an array object wrapper which will not be recognized by Oracle as a proper datatype
        }
        $r = OCIExecute($statement, OCI_DEFAULT);
        if (!$r) {
            echo "<br>Cannot execute the following command: " . $cmdstr . "<br>";
            $e = OCI_Error($statement);
            // For OCIExecute errors pass the statementhandle
            echo htmlentities($e['message']);
            echo "<br>";
            $success = False;
        }
    }
}
开发者ID:dchanman,项目名称:tinder-plus-plus,代码行数:34,代码来源:sql-cmds.php

示例3: add_image

function add_image($name, $imagetype, $file)
{
    if (!is_null($file)) {
        if ($file["error"] != 0 || $file["size"] == 0) {
            error("Incorrect Image");
        } else {
            if ($file["size"] < 1024 * 1024) {
                global $DB;
                $imageid = get_dbid("images", "imageid");
                $image = fread(fopen($file["tmp_name"], "r"), filesize($file["tmp_name"]));
                if ($DB['TYPE'] == "ORACLE") {
                    DBstart();
                    $lobimage = OCINewDescriptor($DB['DB'], OCI_D_LOB);
                    $stid = OCIParse($DB['DB'], "insert into images (imageid,name,imagetype,image)" . " values ({$imageid}," . zbx_dbstr($name) . "," . $imagetype . ",EMPTY_BLOB())" . " return image into :image");
                    if (!$stid) {
                        $e = ocierror($stid);
                        error("Parse SQL error [" . $e["message"] . "] in [" . $e["sqltext"] . "]");
                        return false;
                    }
                    OCIBindByName($stid, ':image', $lobimage, -1, OCI_B_BLOB);
                    if (!OCIExecute($stid, OCI_DEFAULT)) {
                        $e = ocierror($stid);
                        error("Execute SQL error [" . $e["message"] . "] in [" . $e["sqltext"] . "]");
                        return false;
                    }
                    $result = DBend($lobimage->save($image));
                    if (!$result) {
                        error("Couldn't save image!\n");
                        return false;
                    }
                    $lobimage->free();
                    OCIFreeStatement($stid);
                    return $stid;
                } else {
                    if ($DB['TYPE'] == "POSTGRESQL") {
                        $image = pg_escape_bytea($image);
                    } else {
                        if ($DB['TYPE'] == "SQLITE3") {
                            $image = bin2hex($image);
                        }
                    }
                }
                return DBexecute("insert into images (imageid,name,imagetype,image)" . " values ({$imageid}," . zbx_dbstr($name) . "," . $imagetype . "," . zbx_dbstr($image) . ")");
            } else {
                error("Image size must be less than 1Mb");
            }
        }
    } else {
        error("Select image to download");
    }
    return false;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:52,代码来源:images.inc.php

示例4: QueryB

function QueryB($sql)
{
    global $conn;
    $stmt = OCIParse($conn, $sql);
    $DBody = OCINewDescriptor($conn, OCI_D_LOB);
    OCIBindByName($stmt, ":Body_Loc", $DBody, -1, OCI_B_BLOB);
    $err = OCIExecute($stmt, OCI_DEFAULT);
    if (!$err) {
        $error = OCIError($stmt);
        //echo '<strong>Произошла ошибка: <font color="#889999">'.$error["message"].'</font><br>Запрос: <font color="#889999">'.$error["sqltext"].'</font></strong>';
        QError($error);
        die;
    }
    return $DBody;
}
开发者ID:alaevka,项目名称:stigit.basalt,代码行数:15,代码来源:security.php

示例5: retrieveImage

 function retrieveImage($db, $id, $table, $column)
 {
     // the function OCINewDescriptor allocates storage to hold descriptors or
     // lob locators,
     // see http://www.php.net/manual/en/function.ocinewdescriptor.php
     $data;
     $blob = OCINewDescriptor($db, OCI_D_LOB);
     // construct the sql query with which we will get the media's data
     $sql = "DECLARE\n                        obj ORDSYS.ORDImage;\n                BEGIN\n                        SELECT {$column} INTO obj FROM {$table} WHERE picture_id = :id;\n                        :extblob := obj.getContent;\n                END;";
     $sql = strtr($sql, chr(13) . chr(10), " ");
     $stmt = OCIParse($db, $sql);
     // the function OCIBindByName binds a PHP variable to a oracle placeholder
     // (wheter the variable will be used for input or output will be determined
     // run-time, and the necessary storage space will be allocated)
     // see http://www.php.net/manual/en/function.ocibindbyname.php
     OCIBindByName($stmt, ':extBlob', $blob, -1, OCI_B_BLOB);
     OCIBindByName($stmt, ':id', $id);
     OCIExecute($stmt, OCI_DEFAULT);
     // load the binary data
     $data = $blob->load();
     return $data;
 }
开发者ID:GeorgesAlkhouri,项目名称:openmuseum,代码行数:22,代码来源:DbImageRetriever.php

示例6: array

 /**
  * Execute a prepared query statement helper method.
  *
  * @param mixed $result_class string which specifies which result class to use
  * @param mixed $result_wrap_class string which specifies which class to wrap results in
  * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
  * @access private
  */
 function &_execute($result_class = true, $result_wrap_class = false)
 {
     if (is_null($this->statement)) {
         $result =& parent::_execute($result_class, $result_wrap_class);
         return $result;
     }
     $this->db->last_query = $this->query;
     $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'pre', 'parameters' => $this->values));
     if ($this->db->getOption('disable_query')) {
         $result = $this->is_manip ? 0 : null;
         return $result;
     }
     $connection = $this->db->getConnection();
     if (PEAR::isError($connection)) {
         return $connection;
     }
     $result = MDB2_OK;
     $lobs = $quoted_values = array();
     $i = 0;
     foreach ($this->positions as $parameter) {
         if (!array_key_exists($parameter, $this->values)) {
             return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'Unable to bind to missing placeholder: ' . $parameter, __FUNCTION__);
         }
         $value = $this->values[$parameter];
         $type = array_key_exists($parameter, $this->types) ? $this->types[$parameter] : null;
         if ($type == 'clob' || $type == 'blob') {
             $lobs[$i]['file'] = false;
             if (is_resource($value)) {
                 $fp = $value;
                 $value = '';
                 while (!feof($fp)) {
                     $value .= fread($fp, 8192);
                 }
             } elseif (preg_match('/^(\\w+:\\/\\/)(.*)$/', $value, $match)) {
                 $lobs[$i]['file'] = true;
                 if ($match[1] == 'file://') {
                     $value = $match[2];
                 }
             }
             $lobs[$i]['value'] = $value;
             $lobs[$i]['descriptor'] = @OCINewDescriptor($connection, OCI_D_LOB);
             if (!is_object($lobs[$i]['descriptor'])) {
                 $result = $this->db->raiseError(null, null, null, 'Unable to create descriptor for LOB in parameter: ' . $parameter, __FUNCTION__);
                 break;
             }
             $lob_type = $type == 'blob' ? OCI_B_BLOB : OCI_B_CLOB;
             if (!@OCIBindByName($this->statement, ':' . $parameter, $lobs[$i]['descriptor'], -1, $lob_type)) {
                 $result = $this->db->raiseError($this->statement, null, null, 'could not bind LOB parameter', __FUNCTION__);
                 break;
             }
         } else {
             $quoted_values[$i] = $this->db->quote($value, $type, false);
             if (PEAR::isError($quoted_values[$i])) {
                 return $quoted_values[$i];
             }
             if (!@OCIBindByName($this->statement, ':' . $parameter, $quoted_values[$i])) {
                 $result = $this->db->raiseError($this->statement, null, null, 'could not bind non LOB parameter', __FUNCTION__);
                 break;
             }
         }
         ++$i;
     }
     $lob_keys = array_keys($lobs);
     if (!PEAR::isError($result)) {
         $mode = !empty($lobs) || $this->db->in_transaction ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS;
         if (!@OCIExecute($this->statement, $mode)) {
             $err =& $this->db->raiseError($this->statement, null, null, 'could not execute statement', __FUNCTION__);
             return $err;
         }
         if (!empty($lobs)) {
             foreach ($lob_keys as $i) {
                 if (!is_null($lobs[$i]['value']) && $lobs[$i]['value'] !== '') {
                     if ($lobs[$i]['file']) {
                         $result = $lobs[$i]['descriptor']->savefile($lobs[$i]['value']);
                     } else {
                         $result = $lobs[$i]['descriptor']->save($lobs[$i]['value']);
                     }
                     if (!$result) {
                         $result = $this->db->raiseError(null, null, null, 'Unable to save descriptor contents', __FUNCTION__);
                         break;
                     }
                 }
             }
             if (!PEAR::isError($result)) {
                 if (!$this->db->in_transaction) {
                     if (!@OCICommit($connection)) {
                         $result = $this->db->raiseError(null, null, null, 'Unable to commit transaction', __FUNCTION__);
                     }
                 } else {
                     ++$this->db->uncommitedqueries;
                 }
             }
//.........这里部分代码省略.........
开发者ID:Rudi9719,项目名称:lucid,代码行数:101,代码来源:oci8.php

示例7: alert

$amount = $_POST["amount"];
$refrence = $_POST["refrence"];
$transtype = 'PURCHASE';
$desc = $_POST["desc"];
$bid = $_SESSION['Branchcode'];
if ($amount <= 499) {
    echo "<SCRIPT LANGUAGE='JavaScript'>\r        alert('Sorry, you can only make a purchase above KSh[500], thank you!')\r        window.location.href='../indpurchase.php?id={$member}&acid={$account}'\t\r        </SCRIPT>";
} else {
    if ($reference == '') {
        echo "<SCRIPT LANGUAGE='JavaScript'>\r        window.alert('Please enter a valid Reference code, thank you!')\r        window.location.href='../indpurchase.php?id={$member}&acid={$account}'\t\r        </SCRIPT>";
    } else {
        $mysql = "select AMOUNT, PORTFOLIO, BANKACCDETS, DOC_NO FROM TRANS_AMOUNT WHERE DOC_NO='" . $refrence . "'";
        $resbank = oci_parse($conn, $mysql) or die(" ");
        oci_execute($resbank);
        $numrows = oci_fetch_all($resbank, $res);
        if ($numrows <= 0) {
            $sql = "INSERT INTO trans_amount(trans_type,member_no, full_name,account_no, amount,portfolio,mop, u_name, doc_no, bnkcode, BANKACCDETS ) VALUES('" . $transtype . "','" . $member . "','" . $name . "','" . $account . "','" . $amount . "','" . $desc . "','Funds Transfer','" . $_SESSION['username'] . "','" . $refrence . "','" . $_SESSION['Branchcode'] . "','" . $_SESSION['Branchname'] . "')  returning TRANS_ID into :id ";
            $result = OCIParse($conn, $sql);
            OCIBindByName($result, ":ID", $id, 32);
            OCI_Execute($result);
            if (!oci_parse($conn, $sql)) {
                echo "<SCRIPT LANGUAGE='JavaScript'>\r\t\t\t\r\t\t\t\r\r\$('#content').notifyModal({\r\r\t\t\t\r\rduration : 2500,\r\r\t\t\t\r\rplacement : 'center',\r\r\t\t\t\r\roverlay : true,\r\r\t\t\t\r\rtype : 'notify',\r\r\t\t\t\r\ronClose : function(){ }\r});\r\r\t\t'\r\t\t\t</SCRIPT>";
            } else {
                oci_close($conn);
                echo "<SCRIPT LANGUAGE='JavaScript'>\r\t\t\twindow.alert('Purchase Posted successfully, Transaction ID [{$id}].')\r\t\t\twindow.location.href='../indsearch.php'\r\t\t\t</SCRIPT>";
            }
        } else {
            echo "<SCRIPT LANGUAGE='JavaScript'>\r        window.alert('Sorry the Refference Number already been used. Please Enter the correct Refference ID from Finacle!')\r\t\twindow.location.href='../indpurchase.php?id={$member}&acid={$account}'\t\t\r        </SCRIPT>";
        }
    }
}
开发者ID:Kemallyson,项目名称:Wizglobal,代码行数:31,代码来源:save.php

示例8: sqlCompile

function sqlCompile($Query_String)
{
    $db = new clsDBdatabase();
    $db->Provider->sqoe = 0;
    $esto = array(chr(10), chr(9), chr(13));
    $porEsto = array("\n", "\t", " ");
    $parse = '
	declare
		c integer := dbms_sql.open_cursor();
	begin
		dbms_sql.parse(c, :STMT, dbms_sql.native);
		dbms_sql.close_cursor(c);
	end;
	';
    $plsql = trim(str_replace($esto, $porEsto, $Query_String));
    #echo $plsql ;
    #$Query_String = 'select a from dual';
    $db->bind('STMT', $plsql, 4000, SQLT_CHR);
    #$db->query('BEGIN '.trim(str_replace($esto, $porEsto, $parse)).' END;');
    $db->Query_ID = OCIParse($db->Link_ID, 'BEGIN ' . trim(str_replace($esto, $porEsto, $parse)) . ' END;');
    if (!$db->Query_ID) {
        $db->Error = OCIError($db->Link_ID);
        echo 'ERROR ' . OCIError($db->Link_ID);
    }
    if (sizeof($db->Provider->Binds) > 0) {
        foreach ($db->Provider->Binds as $parameter_name => $parameter_values) {
            if ($parameter_values[2] == OCI_B_CURSOR) {
                $this->db[$parameter_name][0] = OCINewCursor($db->Link_ID);
            }
            if ($parameter_values[2] == 0) {
                OCIBindByName($db->Query_ID, ":" . $parameter_name, $db->Provider->Binds[$parameter_name][0], $parameter_values[1]);
            } else {
                OCIBindByName($db->Query_ID, ":" . $parameter_name, $db->Provider->Binds[$parameter_name][0], $parameter_values[1], $parameter_values[2]);
            }
        }
    }
    @OCIExecute($db->Query_ID);
    $db->Error = OCIError($db->Query_ID);
    #var_dump($db->Error);
    $SQLCODE = $db->Error['code'];
    $SQLERRMSG = explode('ORA-06512', $db->Error['message']);
    $SQLERRMSG = $SQLERRMSG[0];
    $error = new stdClass();
    $error->SQLCODE = !$SQLCODE ? 0 : $SQLCODE;
    $error->SQLERRMSG = $SQLERRMSG;
    return $error;
}
开发者ID:santo-s,项目名称:do_sql.js,代码行数:47,代码来源:do_sql_from_string.php

示例9: doProcedure

 /**
  * Lance une procédure stockées sur la connextion courante
  * @param string $pProcedure la procédure a lancer
  * @param array $pParams un tableau de paramètre à donner à la procédure
  *  le tableau est de la forme $pParams['nom'] = array ('type'=>, 'length'), 'in'=>, ''
  * @return array un tableau de résultat avec array['results'] = résultats,
  *    array['params']['nomParam'] = valeur
  */
 public function doProcedure($pProcedure, $pParams)
 {
     CopixLog::log($pProcedure . var_export($pParams, true), 'query', CopixLog::INFORMATION);
     //Préparation de la requête
     $stmt = @ociparse($this->_ct, $pProcedure);
     if ($stmt === false) {
         throw new CopixDBException('[CopixDB] Impossible de préparer la procédure ' . $pProcedure);
     }
     //On analyse les paramètres
     $arVariablesName = array();
     $arVariables = array();
     foreach ($pParams as $name => $param) {
         $variableName = substr($name, 1);
         if (!is_array($param)) {
             ${$variableName} = $param;
             if (!OCIBindByName($stmt, $name, ${$variableName}, 255)) {
                 throw new Exception("[CopixDB] Impossible de rapprocher '{$name}' avec '" . ${$variableName} . "' taille " . $arVariables[$variableName]['maxlength'] . " type " . $this->_convertQueryParam($arVariables[$variableName]['type']));
             }
             $arVariables[$variableName]['type'] = 'AUTO';
             $arVariables[$variableName]['value'] = $param;
         } else {
             if (!isset(${$variableName})) {
                 ${$variableName} = isset($param['value']) ? $param['value'] : null;
             }
             $arVariables[$variableName] = $param;
             if (!isset($arVariables[$variableName]['type'])) {
                 $arVariables[$variableName]['type'] = CopixDBQueryParam::DB_AUTO;
             }
             if (!isset($arVariables[$variableName]['maxlength'])) {
                 $arVariables[$variableName]['maxlength'] = -1;
             }
             if ($arVariables[$variableName]['type'] === CopixDBQueryParam::DB_CURSOR) {
                 ${$variableName} = oci_new_cursor($this->_ct);
             }
             if (!OCIBindByName($stmt, $name, ${$variableName}, $arVariables[$variableName]['maxlength'], $this->_convertQueryParam($arVariables[$variableName]['type']))) {
                 oci_free_statement($stmt);
                 throw new CopixDBException("[CopixDB] Impossible de rapprocher '{$name}' avec '" . ${$variableName} . "' taille " . $arVariables[$variableName]['maxlength'] . " type " . $this->_convertQueryParam($arVariables[$variableName]['type']));
             }
         }
     }
     //on exécute la requête
     if (!ociexecute($stmt, OCI_DEFAULT)) {
         $statementErrors = oci_error($stmt);
         oci_free_statement($stmt);
         throw new CopixDBException('[CopixDB] Impossible d\'exécuter la procédure ' . $pProcedure . ' - ' . var_dump($statementErrors) . ' avec les variables ' . var_dump($arVariables));
     }
     //analyse des résultats
     foreach ($arVariables as $name => $value) {
         //Si c'est un curseur
         if ($value['type'] === CopixDBQueryParam::DB_CURSOR) {
             if (!@ociexecute(${$name})) {
                 oci_free_statement(${$name});
                 oci_free_statement($stmt);
                 throw new CopixDBException("Impossible de récupérer l'ensemble de résultat de la variable {$name}");
             }
             $toReturn[':' . $name] = array();
             while ($r = oci_fetch_object(${$name})) {
                 $toReturn[':' . $name][] = $r;
             }
             oci_free_statement(${$name});
         } else {
             $toReturn[':' . $name] = ${$name};
         }
     }
     //On commit si le mode est autocommit
     if ($this->_autoCommitMode == self::OCI_AUTO_COMMIT) {
         $this->commit();
     }
     oci_free_statement($stmt);
     CopixLog::log('Terminé', 'Procedure');
     return $toReturn;
 }
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:80,代码来源:CopixDbConnection.oci.class.php

示例10: array

 /**
  * Executes a DB statement prepared with prepare().
  *
  * To determine how many rows of a result set get buffered using
  * ocisetprefetch(), see the "result_buffering" option in setOptions().
  * This option was added in Release 1.7.0.
  *
  * @param resource  $stmt  a DB statement resource returned from prepare()
  * @param mixed  $data  array, string or numeric data to be used in
  *                      execution of the statement.  Quantity of items
  *                      passed must match quantity of placeholders in
  *                      query:  meaning 1 for non-array items or the
  *                      quantity of elements in the array.
  *
  * @return mixed  returns an oic8 result resource for successful SELECT
  *                queries, DB_OK for other successful queries.
  *                A DB error object is returned on failure.
  *
  * @see DB_oci8::prepare()
  */
 function &execute($stmt, $data = array())
 {
     $data = (array) $data;
     $this->last_parameters = $data;
     $this->last_query = $this->_prepared_queries[(int) $stmt];
     $this->_data = $data;
     $types = $this->prepare_types[(int) $stmt];
     if (count($types) != count($data)) {
         $tmp = $this->raiseError(DB_ERROR_MISMATCH);
         return $tmp;
     }
     $i = 0;
     foreach ($data as $key => $value) {
         if ($types[$i] == DB_PARAM_MISC) {
             /*
              * Oracle doesn't seem to have the ability to pass a
              * parameter along unchanged, so strip off quotes from start
              * and end, plus turn two single quotes to one single quote,
              * in order to avoid the quotes getting escaped by
              * Oracle and ending up in the database.
              */
             $data[$key] = preg_replace("/^'(.*)'\$/", "\\1", $data[$key]);
             $data[$key] = str_replace("''", "'", $data[$key]);
         } elseif ($types[$i] == DB_PARAM_OPAQUE) {
             $fp = @fopen($data[$key], 'rb');
             if (!$fp) {
                 $tmp = $this->raiseError(DB_ERROR_ACCESS_VIOLATION);
                 return $tmp;
             }
             $data[$key] = fread($fp, filesize($data[$key]));
             fclose($fp);
         } elseif ($types[$i] == DB_PARAM_SCALAR) {
             // Floats have to be converted to a locale-neutral
             // representation.
             if (is_float($data[$key])) {
                 $data[$key] = $this->quoteFloat($data[$key]);
             }
         }
         if (!@OCIBindByName($stmt, ':bind' . $i, $data[$key], -1)) {
             $tmp = $this->oci8RaiseError($stmt);
             return $tmp;
         }
         $this->last_query = str_replace(':bind' . $i, $this->quoteSmart($data[$key]), $this->last_query);
         $i++;
     }
     if ($this->autocommit) {
         $success = @OCIExecute($stmt, OCI_COMMIT_ON_SUCCESS);
     } else {
         $success = @OCIExecute($stmt, OCI_DEFAULT);
     }
     if (!$success) {
         $tmp = $this->oci8RaiseError($stmt);
         return $tmp;
     }
     $this->last_stmt = $stmt;
     if ($this->manip_query[(int) $stmt] || $this->_next_query_manip) {
         $this->_last_query_manip = true;
         $this->_next_query_manip = false;
         $tmp = DB_OK;
     } else {
         $this->_last_query_manip = false;
         @ocisetprefetch($stmt, $this->options['result_buffering']);
         $tmp = new DB_result($this, $stmt);
     }
     return $tmp;
 }
开发者ID:ranakhurram,项目名称:playSMS,代码行数:86,代码来源:oci8.php

示例11: session_start

/**
 * Created by PhpStorm.
 * User: Allan Wiz
 * Date: 3/25/15
 * Time: 10:16 AM
 */
session_start();
//global $session, $database;
require '../classes/aardb_conn.php';
require '../functions/sanitize.php';
foreach ($_POST as $key => $value) {
    ${$key} = $value;
    //echo $key = $value;
}
//$dobdate=ConvertSDate($dob);
####
//$dob = substr($dob, 0, 10);
//$dob = date("d/m/Y", strtotime($dob));
$stmt = OCIParse($conn, "insert into member_no values (MEMBERNUMBER_SEQ.nextval) returning MEMBERNO into :id");
OCIBindByName($stmt, ":ID", $id, 32);
OCI_Execute($stmt);
if (strlen($id) == 1) {
    $memberno = "0000000{$id}";
} else {
    if (strlen($id) == 2) {
        $memberno = "000000{$id}";
    } else {
        if (strlen($id) == 3) {
            $memberno = "00000{$id}";
        } else {
开发者ID:Kemallyson,项目名称:Wizglobal,代码行数:30,代码来源:save_member.php

示例12: insertPictureIfNotExists

 function insertPictureIfNotExists($db, $picture)
 {
     $picture->id = $this->dbIdFetcher->fetchPictureId($db, $picture);
     if (is_null($picture->id)) {
         $sql = "INSERT INTO pictures (\n                    picture_id, name, description,\n                    image, image_sig,\n                    creation_date, upload_date,\n                    artist_fk, artist_safety_level,\n                    museum_ownes_fk, museum_exhibits_fk,\n                    museum_exhibits_startdate, museum_exhibits_enddate,\n                    owner_fk)\n                    VALUES (pictures_seq.nextval,\n                    '{$picture->name}',\n                    '{$picture->description}',\n                    ORDSYS.ORDImage.init(),\n                    ORDSYS.ORDImageSignature.init(),\n                    TO_DATE('{$picture->creation_date}', 'dd.mm.yyyy'),\n                    TO_DATE('{$picture->upload_date}', 'dd.mm.yyyy'),\n                    {$picture->artist_fk},\n                    {$picture->artist_safety_level},";
         /** Add Optional Parameters **/
         if (empty($picture->museum_owns_fk)) {
             $sql .= "NULL, ";
         } else {
             $sql .= "{$picture->museum_owns_fk} , ";
         }
         if (empty($picture->museum_exhibits_fk)) {
             $sql .= "NULL, NULL, NULL, ";
         } else {
             $sql .= "{$picture->museum_exhibits_fk} ,\n                    TO_DATE('{$picture->museum_exhibits_startdate}', 'dd.mm.yyyy'),\n                    TO_DATE('{$picture->museum_exhibits_enddate}', 'dd.mm.yyyy'), ";
         }
         if (empty($picture->owner_fk)) {
             $sql .= "NULL)";
         } else {
             $sql .= "{$picture->owner_fk})";
         }
         $sql .= "returning picture_id into :picture_id";
         echo "{$this->log} - {$sql} <br />";
         $stmt = oci_parse($db, $sql);
         $currentPictureId;
         OCIBindByName($stmt, ":picture_id", $currentPictureId, 32);
         oci_execute($stmt, OCI_NO_AUTO_COMMIT);
         /** Load image data **/
         $this->dbImageUploader = new DbImageUploader();
         $this->dbImageUploader->uploadImageData($db, $picture->image_path . $picture->image_name, $currentPictureId, 'pictures', 'picture_id');
         /** Create ImageSignature **/
         $sql = "DECLARE imageObj ORDSYS.ORDImage;\n                            image_sigObj ORDSYS.ORDImageSignature;\n                    BEGIN\n                        SELECT image, image_sig INTO imageObj, image_sigObj\n                        FROM pictures WHERE picture_id = {$currentPictureId} FOR UPDATE;\n                        image_sigObj.generateSignature(imageObj);\n                    UPDATE pictures SET image_sig = image_sigObj\n                    WHERE picture_id = {$currentPictureId};\n                    COMMIT; END;";
         echo "{$this->log} - {$sql} <br />";
         $stmt = oci_parse($db, $sql);
         oci_execute($stmt, OCI_NO_AUTO_COMMIT);
         oci_commit($db);
     }
 }
开发者ID:GeorgesAlkhouri,项目名称:openmuseum,代码行数:38,代码来源:DbInserter.php

示例13: array

 /**
  * Executes a DB statement prepared with prepare().
  *
  * @param resource  $stmt  a DB statement resource returned from prepare()
  * @param mixed  $data  array, string or numeric data to be used in
  *                      execution of the statement.  Quantity of items
  *                      passed must match quantity of placeholders in
  *                      query:  meaning 1 for non-array items or the
  *                      quantity of elements in the array.
  * @return int returns an oci8 result resource for successful
  * SELECT queries, DB_OK for other successful queries.  A DB error
  * code is returned on failure.
  * @see DB_oci::prepare()
  */
 function &execute($stmt, $data = array())
 {
     if (!is_array($data)) {
         $data = array($data);
     }
     $this->_data = $data;
     $types =& $this->prepare_types[$stmt];
     if (count($types) != count($data)) {
         $tmp =& $this->raiseError(DB_ERROR_MISMATCH);
         return $tmp;
     }
     $i = 0;
     foreach ($data as $key => $value) {
         if ($types[$i] == DB_PARAM_MISC) {
             /*
              * Oracle doesn't seem to have the ability to pass a
              * parameter along unchanged, so strip off quotes from start
              * and end, plus turn two single quotes to one single quote,
              * in order to avoid the quotes getting escaped by
              * Oracle and ending up in the database.
              */
             $data[$key] = preg_replace("/^'(.*)'\$/", "\\1", $data[$key]);
             $data[$key] = str_replace("''", "'", $data[$key]);
         } elseif ($types[$i] == DB_PARAM_OPAQUE) {
             $fp = @fopen($data[$key], 'rb');
             if (!$fp) {
                 $tmp =& $this->raiseError(DB_ERROR_ACCESS_VIOLATION);
                 return $tmp;
             }
             $data[$key] = fread($fp, filesize($data[$key]));
             fclose($fp);
         }
         if (!@OCIBindByName($stmt, ':bind' . $i, $data[$key], -1)) {
             $tmp = $this->oci8RaiseError($stmt);
             return $tmp;
         }
         $i++;
     }
     if ($this->autoCommit) {
         $success = @OCIExecute($stmt, OCI_COMMIT_ON_SUCCESS);
     } else {
         $success = @OCIExecute($stmt, OCI_DEFAULT);
     }
     if (!$success) {
         $tmp = $this->oci8RaiseError($stmt);
         return $tmp;
     }
     $this->last_stmt = $stmt;
     if ($this->manip_query[(int) $stmt]) {
         $tmp = DB_OK;
     } else {
         $tmp =& new DB_result($this, $stmt);
     }
     return $tmp;
 }
开发者ID:mickdane,项目名称:zidisha,代码行数:69,代码来源:oci8.php

示例14: _doQuery

 /**
  * Execute a query
  * @param string $query the SQL query
  * @return mixed result identifier if query executed, else MDB2_error
  * @access private
  **/
 function _doQuery($query, $ismanip = null, $prepared_query = 0)
 {
     $lobs = 0;
     $success = MDB2_OK;
     $result = 0;
     $descriptors = array();
     if ($prepared_query) {
         $columns = '';
         $variables = '';
         for (reset($this->clobs[$prepared_query]), $clob = 0; $clob < count($this->clobs[$prepared_query]); $clob++, next($this->clobs[$prepared_query])) {
             $clob_stream = key($this->clobs[$prepared_query]);
             $descriptors[$clob_stream] = @OCINewDescriptor($this->connection, OCI_D_LOB);
             if (!is_object($descriptors[$clob_stream])) {
                 $success = $this->raiseError(MDB2_ERROR, null, null, 'Could not create descriptor for clob parameter');
                 break;
             }
             $parameter = $GLOBALS['_MDB2_LOBs'][$clob_stream]->parameter;
             $columns .= ($lobs == 0 ? ' RETURNING ' : ',') . $this->prepared_queries[$prepared_query - 1]['fields'][$parameter - 1];
             $variables .= ($lobs == 0 ? ' INTO ' : ',') . ':clob' . $parameter;
             ++$lobs;
         }
         if (!MDB2::isError($success)) {
             for (reset($this->blobs[$prepared_query]), $blob = 0; $blob < count($this->blobs[$prepared_query]); $blob++, next($this->blobs[$prepared_query])) {
                 $blob_stream = key($this->blobs[$prepared_query]);
                 $descriptors[$blob_stream] = @OCINewDescriptor($this->connection, OCI_D_LOB);
                 if (!is_object($descriptors[$blob_stream])) {
                     $success = $this->raiseError(MDB2_ERROR, null, null, 'Could not create descriptor for blob parameter');
                     break;
                 }
                 $parameter = $GLOBALS['_MDB2_LOBs'][$blob_stream]->parameter;
                 $columns .= ($lobs == 0 ? ' RETURNING ' : ',') . $this->prepared_queries[$prepared_query - 1]['fields'][$parameter - 1];
                 $variables .= ($lobs == 0 ? ' INTO ' : ',') . ':blob' . $parameter;
                 ++$lobs;
             }
             $query .= $columns . $variables;
         }
     }
     if (!MDB2::isError($success)) {
         if ($statement = @OCIParse($this->connection, $query)) {
             if ($lobs) {
                 for (reset($this->clobs[$prepared_query]), $clob = 0; $clob < count($this->clobs[$prepared_query]); $clob++, next($this->clobs[$prepared_query])) {
                     $clob_stream = key($this->clobs[$prepared_query]);
                     $parameter = $GLOBALS['_MDB2_LOBs'][$clob_stream]->parameter;
                     if (!OCIBindByName($statement, ':clob' . $parameter, $descriptors[$clob_stream], -1, OCI_B_CLOB)) {
                         $success = $this->raiseError();
                         break;
                     }
                 }
                 if (!MDB2::isError($success)) {
                     for (reset($this->blobs[$prepared_query]), $blob = 0; $blob < count($this->blobs[$prepared_query]); $blob++, next($this->blobs[$prepared_query])) {
                         $blob_stream = key($this->blobs[$prepared_query]);
                         $parameter = $GLOBALS['_MDB2_LOBs'][$blob_stream]->parameter;
                         if (!OCIBindByName($statement, ':blob' . $parameter, $descriptors[$blob_stream], -1, OCI_B_BLOB)) {
                             $success = $this->raiseError();
                             break;
                         }
                     }
                 }
             }
             if (!MDB2::isError($success)) {
                 $mode = $lobs == 0 && $this->auto_commit ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT;
                 $result = @OCIExecute($statement, $mode);
                 if ($result) {
                     if ($lobs) {
                         for (reset($this->clobs[$prepared_query]), $clob = 0; $clob < count($this->clobs[$prepared_query]); $clob++, next($this->clobs[$prepared_query])) {
                             $clob_stream = key($this->clobs[$prepared_query]);
                             for ($value = ''; !$this->datatype->endOfLOB($clob_stream);) {
                                 if ($this->datatype->readLOB($clob_stream, $data, $this->options['lob_buffer_length']) < 0) {
                                     $success = $this->raiseError();
                                     break;
                                 }
                                 $value .= $data;
                             }
                             if (!MDB2::isError($success) && !$descriptors[$clob_stream]->save($value)) {
                                 $success = $this->raiseError();
                             }
                         }
                         if (!MDB2::isError($success)) {
                             for (reset($this->blobs[$prepared_query]), $blob = 0; $blob < count($this->blobs[$prepared_query]); $blob++, next($this->blobs[$prepared_query])) {
                                 $blob_stream = key($this->blobs[$prepared_query]);
                                 for ($value = ''; !$this->datatype->endOfLOB($blob_stream);) {
                                     if ($this->datatype->readLOB($blob_stream, $data, $this->options['lob_buffer_length']) < 0) {
                                         $success = $this->raiseError();
                                         break;
                                     }
                                     $value .= $data;
                                 }
                                 if (!MDB2::isError($success) && !$descriptors[$blob_stream]->save($value)) {
                                     $success = $this->raiseError();
                                 }
                             }
                         }
                     }
                     if ($this->auto_commit) {
//.........这里部分代码省略.........
开发者ID:GeekyNinja,项目名称:LifesavingCAD,代码行数:101,代码来源:oci8.php

示例15: _doQuery

 /**
  * all the RDBMS specific things needed close a DB connection
  * 
  * @access private
  */
 function _doQuery($query, $first = 0, $limit = 0, $prepared_query = 0)
 {
     $lobs = 0;
     $success = MDB_OK;
     $result = 0;
     $descriptors = array();
     if ($prepared_query) {
         $columns = '';
         $variables = '';
         for (reset($this->clobs[$prepared_query]), $clob = 0; $clob < count($this->clobs[$prepared_query]); $clob++, next($this->clobs[$prepared_query])) {
             $position = key($this->clobs[$prepared_query]);
             if (gettype($descriptors[$position] = @OCINewDescriptor($this->connection, OCI_D_LOB)) != 'object') {
                 $success = $this->raiseError(MDB_ERROR, NULL, NULL, 'Do query: Could not create descriptor for clob parameter');
                 break;
             }
             $columns .= ($lobs == 0 ? ' RETURNING ' : ',') . $this->prepared_queries[$prepared_query - 1]['Fields'][$position - 1];
             $variables .= ($lobs == 0 ? ' INTO ' : ',') . ':clob' . $position;
             $lobs++;
         }
         if (!MDB::isError($success)) {
             for (reset($this->blobs[$prepared_query]), $blob = 0; $blob < count($this->blobs[$prepared_query]); $blob++, next($this->blobs[$prepared_query])) {
                 $position = key($this->blobs[$prepared_query]);
                 if (gettype($descriptors[$position] = @OCINewDescriptor($this->connection, OCI_D_LOB)) != 'object') {
                     $success = $this->raiseError(MDB_ERROR, NULL, NULL, 'Do query: Could not create descriptor for blob parameter');
                     break;
                 }
                 $columns .= ($lobs == 0 ? ' RETURNING ' : ',') . $this->prepared_queries[$prepared_query - 1]['Fields'][$position - 1];
                 $variables .= ($lobs == 0 ? ' INTO ' : ',') . ':blob' . $position;
                 $lobs++;
             }
             $query .= $columns . $variables;
         }
     }
     if (!MDB::isError($success)) {
         if ($statement = @OCIParse($this->connection, $query)) {
             if ($lobs) {
                 for (reset($this->clobs[$prepared_query]), $clob = 0; $clob < count($this->clobs[$prepared_query]); $clob++, next($this->clobs[$prepared_query])) {
                     $position = key($this->clobs[$prepared_query]);
                     if (!@OCIBindByName($statement, ':clob' . $position, $descriptors[$position], -1, OCI_B_CLOB)) {
                         $success = $this->oci8RaiseError(NULL, 'Do query: Could not bind clob upload descriptor');
                         break;
                     }
                 }
                 if (!MDB::isError($success)) {
                     for (reset($this->blobs[$prepared_query]), $blob = 0; $blob < count($this->blobs[$prepared_query]); $blob++, next($this->blobs[$prepared_query])) {
                         $position = key($this->blobs[$prepared_query]);
                         if (!@OCIBindByName($statement, ':blob' . $position, $descriptors[$position], -1, OCI_B_BLOB)) {
                             $success = $this->oci8RaiseError(NULL, 'Do query: Could not bind blob upload descriptor');
                             break;
                         }
                     }
                 }
             }
             if (!MDB::isError($success)) {
                 if ($result = @OCIExecute($statement, $lobs == 0 && $this->auto_commit ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT)) {
                     if ($lobs) {
                         for (reset($this->clobs[$prepared_query]), $clob = 0; $clob < count($this->clobs[$prepared_query]); $clob++, next($this->clobs[$prepared_query])) {
                             $position = key($this->clobs[$prepared_query]);
                             $clob_stream = $this->prepared_queries[$prepared_query - 1]['Values'][$position - 1];
                             for ($value = ''; !$this->endOfLOB($clob_stream);) {
                                 if ($this->readLOB($clob_stream, $data, $this->getOption('lob_buffer_length')) < 0) {
                                     $success = $this->raiseError();
                                     break;
                                 }
                                 $value .= $data;
                             }
                             if (!MDB::isError($success) && !$descriptors[$position]->save($value)) {
                                 $success = $this->oci8RaiseError(NULL, 'Do query: Could not upload clob data');
                             }
                         }
                         if (!MDB::isError($success)) {
                             for (reset($this->blobs[$prepared_query]), $blob = 0; $blob < count($this->blobs[$prepared_query]); $blob++, next($this->blobs[$prepared_query])) {
                                 $position = key($this->blobs[$prepared_query]);
                                 $blob_stream = $this->prepared_queries[$prepared_query - 1]['Values'][$position - 1];
                                 for ($value = ''; !$this->endOfLOB($blob_stream);) {
                                     if ($this->readLOB($blob_stream, $data, $this->getOption('lob_buffer_length')) < 0) {
                                         $success = $this->raiseError();
                                         break;
                                     }
                                     $value .= $data;
                                 }
                                 if (!MDB::isError($success) && !$descriptors[$position]->save($value)) {
                                     $success = $this->oci8RaiseError(NULL, 'Do query: Could not upload blob data');
                                 }
                             }
                         }
                     }
                     if ($this->auto_commit) {
                         if ($lobs) {
                             if (MDB::isError($success)) {
                                 if (!@OCIRollback($this->connection)) {
                                     $success = $this->oci8RaiseError(NULL, 'Do query: ' . $success->getUserinfo() . ' and then could not rollback LOB updating transaction');
                                 }
                             } else {
                                 if (!@OCICommit($this->connection)) {
//.........这里部分代码省略.........
开发者ID:GeekyNinja,项目名称:LifesavingCAD,代码行数:101,代码来源:oci8.php


注:本文中的OCIBindByName函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。