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


PHP OCINumCols函数代码示例

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


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

示例1: numCols

 /**
  * Get the number of columns in a result set.
  *
  * @param $result oci8 result identifier
  *
  * @return int the number of columns per row in $result
  */
 function numCols($result)
 {
     $cols = @OCINumCols($result);
     if (!$cols) {
         return $this->oci8RaiseError($result);
     }
     return $cols;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:15,代码来源:oci8.php

示例2: tableInfo

 /**
  * Returns information about a table or a result set.
  *
  * NOTE: only supports 'table' and 'flags' if <var>$result</var>
  * is a table name.
  *
  * NOTE: flags won't contain index information.
  *
  * @param object|string  $result  MDB2_result object from a query or a
  *                                string containing the name of a table
  * @param int            $mode    a valid tableInfo mode
  * @return array  an associative array with the information requested
  *                or an error object if something is wrong
  * @access public
  * @internal
  * @see MDB2_Driver_Common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     $db =& $GLOBALS['_MDB2_databases'][$this->db_index];
     if ($db->options['portability'] & MDB2_PORTABILITY_LOWERCASE) {
         $case_func = 'strtolower';
     } else {
         $case_func = 'strval';
     }
     if (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         if (MDB2::isError($connect = $db->connect())) {
             return $connect;
         }
         $result = strtoupper($result);
         $q_fields = 'SELECT column_name, data_type, data_length, ' . 'nullable ' . 'FROM user_tab_columns ' . "WHERE table_name='{$result}' ORDER BY column_id";
         $db->last_query = $q_fields;
         if (!($stmt = @OCIParse($db->connection, $q_fields))) {
             return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA);
         }
         if (!@OCIExecute($stmt, OCI_DEFAULT)) {
             return $db->raiseError($stmt);
         }
         $i = 0;
         while (@OCIFetch($stmt)) {
             $res[$i]['table'] = $case_func($result);
             $res[$i]['name'] = $case_func(@OCIResult($stmt, 1));
             $res[$i]['type'] = @OCIResult($stmt, 2);
             $res[$i]['len'] = @OCIResult($stmt, 3);
             $res[$i]['flags'] = @OCIResult($stmt, 4) == 'N' ? 'not_null' : '';
             if ($mode & MDB2_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
             $i++;
         }
         if ($mode) {
             $res['num_fields'] = $i;
         }
         @OCIFreeStatement($stmt);
     } else {
         /*
          * Probably received a result object.
          * Extract the result resource identifier.
          */
         $id = $result->getResource();
         if (empty($id)) {
             return $db->raiseError();
         }
         #            if ($result === $db->last_stmt) {
         $count = @OCINumCols($id);
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = '';
             $res[$i]['name'] = $case_func(@OCIColumnName($id, $i + 1));
             $res[$i]['type'] = @OCIColumnType($id, $i + 1);
             $res[$i]['len'] = @OCIColumnSize($id, $i + 1);
             $res[$i]['flags'] = '';
             if ($mode & MDB2_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
         }
         if ($mode) {
             $res['num_fields'] = $i;
         }
         #            } else {
         #                return $db->raiseError(MDB2_ERROR_NOT_CAPABLE);
         #            }
     }
     return $res;
 }
开发者ID:GeekyNinja,项目名称:LifesavingCAD,代码行数:94,代码来源:oci8.php

示例3: numCols

 /**
  * Count the number of columns returned by the DBMS in a query result.
  *
  * @return mixed integer value with the number of columns, a MDB2 error
  *      on failure
  * @access public
  */
 function numCols()
 {
     $cols = @OCINumCols($this->result);
     if (is_null($cols)) {
         if ($this->result === false) {
             return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'resultset has already been freed', __FUNCTION__);
         } elseif (is_null($this->result)) {
             return count($this->types);
         }
         return $this->db->raiseError(null, null, null, 'Could not get column count', __FUNCTION__);
     }
     if ($this->offset > 0) {
         --$cols;
     }
     return $cols;
 }
开发者ID:Rudi9719,项目名称:lucid,代码行数:23,代码来源:oci8.php

示例4: sql_numfields

 function sql_numfields($query_id = 0)
 {
     if (!$query_id) {
         $query_id = $this->query_result;
     }
     if ($query_id) {
         $result = @OCINumCols($query_id);
         return $result;
     } else {
         return false;
     }
 }
开发者ID:damncabbage,项目名称:publicwhip,代码行数:12,代码来源:oracle.php

示例5: num_fields

 /**
  * Get number of fields in a result
  * @param Mixed qHanle		The query handle
  * @return Number
  */
 public function num_fields($qHandle)
 {
     return OCINumCols($qHandle);
 }
开发者ID:ryanblanchard,项目名称:Dashboard,代码行数:9,代码来源:OracleConnection.php

示例6: tableInfo

 /**
  * Returns information about a table or a result set
  *
  * NOTE: only supports 'table' and 'flags' if <var>$result</var>
  * is a table name.
  *
  * NOTE: flags won't contain index information.
  *
  * @param object|string  $result  MDB2_result object from a query or a
  *                                 string containing the name of a table.
  *                                 While this also accepts a query result
  *                                 resource identifier, this behavior is
  *                                 deprecated.
  * @param int            $mode    a valid tableInfo mode
  *
  * @return array  an associative array with the information requested.
  *                 A MDB2_Error object on failure.
  *
  * @see MDB2_Driver_Common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     if (is_string($result)) {
         return parent::tableInfo($result, $mode);
     }
     $db =& $this->getDBInstance();
     if (PEAR::isError($db)) {
         return $db;
     }
     $resource = MDB2::isResultCommon($result) ? $result->getResource() : $result;
     if (!is_resource($resource)) {
         return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'Could not generate result resource', __FUNCTION__);
     }
     if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
         if ($db->options['field_case'] == CASE_LOWER) {
             $case_func = 'strtolower';
         } else {
             $case_func = 'strtoupper';
         }
     } else {
         $case_func = 'strval';
     }
     $count = @OCINumCols($resource);
     $res = array();
     if ($mode) {
         $res['num_fields'] = $count;
     }
     $db->loadModule('Datatype', null, true);
     for ($i = 0; $i < $count; $i++) {
         $column = array('table' => '', 'name' => $case_func(@OCIColumnName($resource, $i + 1)), 'type' => @OCIColumnType($resource, $i + 1), 'length' => @OCIColumnSize($resource, $i + 1), 'flags' => '');
         $res[$i] = $column;
         $res[$i]['mdb2type'] = $db->datatype->mapNativeDatatype($res[$i]);
         if ($mode & MDB2_TABLEINFO_ORDER) {
             $res['order'][$res[$i]['name']] = $i;
         }
         if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
             $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
         }
     }
     return $res;
 }
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:61,代码来源:oci8.php

示例7: tableInfo

 /**
  * Returns information about a table or a result set
  *
  * NOTE: only supports 'table' and 'flags' if <var>$result</var>
  * is a table name.
  *
  * NOTE: flags won't contain index information.
  *
  * @param object|string  $result  DB_result object from a query or a
  *                                 string containing the name of a table.
  *                                 While this also accepts a query result
  *                                 resource identifier, this behavior is
  *                                 deprecated.
  * @param int            $mode    a valid tableInfo mode
  *
  * @return array  an associative array with the information requested.
  *                 A DB_Error object on failure.
  *
  * @see DB_common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
         $case_func = 'strtolower';
     } else {
         $case_func = 'strval';
     }
     $res = array();
     if (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         $result = strtoupper($result);
         $q_fields = 'SELECT column_name, data_type, data_length, ' . 'nullable ' . 'FROM user_tab_columns ' . "WHERE table_name='{$result}' ORDER BY column_id";
         $this->last_query = $q_fields;
         if (!($stmt = @OCIParse($this->connection, $q_fields))) {
             return $this->oci8RaiseError(DB_ERROR_NEED_MORE_DATA);
         }
         if (!@OCIExecute($stmt, OCI_DEFAULT)) {
             return $this->oci8RaiseError($stmt);
         }
         $i = 0;
         while (@OCIFetch($stmt)) {
             $res[$i] = array('table' => $case_func($result), 'name' => $case_func(@OCIResult($stmt, 1)), 'type' => @OCIResult($stmt, 2), 'len' => @OCIResult($stmt, 3), 'flags' => @OCIResult($stmt, 4) == 'N' ? 'not_null' : '');
             if ($mode & DB_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & DB_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
             $i++;
         }
         if ($mode) {
             $res['num_fields'] = $i;
         }
         @OCIFreeStatement($stmt);
     } else {
         if (isset($result->result)) {
             /*
              * Probably received a result object.
              * Extract the result resource identifier.
              */
             $result = $result->result;
         }
         $res = array();
         if ($result === $this->last_stmt) {
             $count = @OCINumCols($result);
             if ($mode) {
                 $res['num_fields'] = $count;
             }
             for ($i = 0; $i < $count; $i++) {
                 $res[$i] = array('table' => '', 'name' => $case_func(@OCIColumnName($result, $i + 1)), 'type' => @OCIColumnType($result, $i + 1), 'len' => @OCIColumnSize($result, $i + 1), 'flags' => '');
                 if ($mode & DB_TABLEINFO_ORDER) {
                     $res['order'][$res[$i]['name']] = $i;
                 }
                 if ($mode & DB_TABLEINFO_ORDERTABLE) {
                     $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
                 }
             }
         } else {
             return $this->raiseError(DB_ERROR_NOT_CAPABLE);
         }
     }
     return $res;
 }
开发者ID:ranakhurram,项目名称:playSMS,代码行数:86,代码来源:oci8.php

示例8: modifyLimitQuery

 /**
  * Emulate the row limit support altering the query
  *
  * @param string $query The query to treat
  * @param int    $from  The row to start to fetch from
  * @param int    $count The offset
  * @return string The modified query
  *
  * @author Tomas V.V.Cox <cox@idecnet.com>
  */
 function modifyLimitQuery($query, $from, $count)
 {
     // Let Oracle return the name of the columns instead of
     // coding a "home" SQL parser
     $q_fields = "SELECT * FROM ({$query}) WHERE NULL = NULL";
     if (!($result = OCIParse($this->connection, $q_fields))) {
         return $this->oci8RaiseError();
     }
     if (!OCIExecute($result, OCI_DEFAULT)) {
         return $this->oci8RaiseError($result);
     }
     $ncols = OCINumCols($result);
     $cols = array();
     for ($i = 1; $i <= $ncols; $i++) {
         $cols[] = OCIColumnName($result, $i);
     }
     $fields = implode(', ', $cols);
     // XXX Test that (tip by John Lim)
     //if(preg_match('/^\s*SELECT\s+/is', $query, $match)) {
     //    // Introduce the FIRST_ROWS Oracle query optimizer
     //    $query = substr($query, strlen($match[0]), strlen($query));
     //    $query = "SELECT /* +FIRST_ROWS */ " . $query;
     //}
     // Construct the query
     // more at: http://marc.theaimsgroup.com/?l=php-db&m=99831958101212&w=2
     // Perhaps this could be optimized with the use of Unions
     $from += 1;
     // in Oracle rownum starts at 1
     $query = "SELECT {$fields} FROM" . "  (SELECT rownum as linenum, {$fields} FROM" . "      ({$query})" . "  WHERE rownum <= " . ($from + $count) . ") WHERE linenum >= {$from}";
     return $query;
 }
开发者ID:BackupTheBerlios,项目名称:e-maku-svn,代码行数:41,代码来源:oci8.php

示例9: NumberOfColumns

 function NumberOfColumns($result)
 {
     if (!isset($this->highest_fetched_row[intval($result)])) {
         $this->SetError("Number of columns", "it was specified an inexisting result set");
         return -1;
     }
     return OCINumCols($result);
 }
开发者ID:BackupTheBerlios,项目名称:zvs,代码行数:8,代码来源:metabase_oci.php

示例10: execute_request


//.........这里部分代码省略.........
             // Connexion
             // eko ($value_config);
             //      $conn = @OCILogon ( $value_config['login'], $value_config['password'], $value_config['db'] ) ;
             $conn = @oci_pconnect($value_config['login'], $value_config['password'], $value_config['db']);
             //global $conn ;
             $conn_error = ocierror();
             // Problème à la connexion
             if ($conn_error) {
                 $INDIC_SVC[0] = $conn_error['code'];
                 $INDIC_SVC[1] = $conn_error['message'];
                 // pas de problème de connexion
             } else {
                 // print $requete;
                 // execution de la raquete
                 $stmt = OCIParse($conn, $requete);
                 // print ( $requete ) ;
                 if (DEBUGSQL and function_exists('eko')) {
                     eko($requete);
                 }
                 OCIExecute($stmt);
                 $INDIC_SVC[0] = $conn_error['code'];
                 $INDIC_SVC[1] = $conn_error['message'];
                 // pas de problème à l'execution de la requete
                 if (!$INDIC_SVC[0]) {
                     // Analyse du type de requete
                     $qry_type = OCIStatementType($stmt);
                     switch ($qry_type) {
                         case "SELECT":
                             $nrows = OCIFetchStatement($stmt, $results);
                             // eko ( "<P>There are $nrows records containing your criteria. ($requete)</P>" ) ;
                             if ($nrows) {
                                 // le nom des colonnes a ramener n'a pas été spécifié ou est *
                                 if (!isset($tab_cols)) {
                                     $ncols = OCINumCols($stmt);
                                     for ($k = 1; $k <= $ncols; $k++) {
                                         $tab_cols[] = OCIColumnName($stmt, $k);
                                     }
                                 }
                                 for ($j = 0; $j < $nrows; $j++) {
                                     if (isset($tab_cols) and is_array($tab_cols)) {
                                         while (list($key, $val) = each($tab_cols)) {
                                             if (isset(${$val})) {
                                                 ${$val} .= $results[$val][$j] . "§";
                                             } else {
                                                 ${$val} = $results[$val][$j] . "§";
                                             }
                                         }
                                     }
                                     reset($tab_cols);
                                 }
                             }
                             //Construction des tableaux de colonnes
                             if (isset($tab_cols) and is_array($tab_cols)) {
                                 while (list($key, $val) = each($tab_cols)) {
                                     // on retire le dernier |
                                     ${$val} = substr(${$val}, 0, strlen(${$val}) - 1);
                                     $resultats[$val] = explode("§", ${$val});
                                 }
                             }
                             $INDIC_SVC[2] = $nrows;
                             break;
                         case "INSERT":
                             $nrows = OCIRowCount($stmt);
                             $INDIC_SVC[2] = $nrows;
                             break;
                         case "UPDATE":
开发者ID:jeromecc,项目名称:tuv2,代码行数:67,代码来源:clResultQuery.php

示例11: query

 function query($query)
 {
     // For reg expressions
     $query = trim($query);
     $return_value = 0;
     // Flush cached values..
     $this->flush();
     // Log how the function was called
     $this->func_call = "\$db->query(\"{$query}\")";
     // Keep track of the last query for debug..
     $this->last_query = $query;
     // Parses the query and returns a statement..
     if (!($stmt = OCIParse($this->dbh, $query))) {
         $this->print_error("Last Query", $query);
     } elseif (!($this->result = OCIExecute($stmt))) {
         $this->print_error("Last Query", $query);
     }
     $this->num_queries++;
     // If query was an insert
     if (preg_match('/^(insert|delete|update|create)\\s+/i', $query)) {
         // num afected rows
         $return_value = $this->rows_affected = OCIRowCount($stmt);
     } else {
         // Get column information
         if ($num_cols = @OCINumCols($stmt)) {
             // Fetch the column meta data
             for ($i = 1; $i <= $num_cols; $i++) {
                 $this->col_info[$i - 1]->name = OCIColumnName($stmt, $i);
                 $this->col_info[$i - 1]->type = OCIColumnType($stmt, $i);
                 $this->col_info[$i - 1]->size = OCIColumnSize($stmt, $i);
             }
         }
         // If there are any results then get them
         if ($this->num_rows = @OCIFetchStatement($stmt, $results)) {
             // Convert results into object orientated results..
             // Due to Oracle strange return structure - loop through columns
             foreach ($results as $col_title => $col_contents) {
                 $row_num = 0;
                 // then - loop through rows
                 foreach ($col_contents as $col_content) {
                     $this->last_result[$row_num]->{$col_title} = $col_content;
                     $row_num++;
                 }
             }
         }
         // num result rows
         $return_value = $this->num_rows;
     }
     // If debug ALL queries
     $this->trace || $this->debug_all ? $this->debug() : null;
     return $return_value;
 }
开发者ID:benvanstaveren,项目名称:movabletype,代码行数:52,代码来源:ezsql_oracle.php

示例12: query

 function query($query)
 {
     //去掉查询语句的前后空格
     $query = trim($query);
     $return_value = 0;
     //清空缓存..
     $this->flush();
     //记录此函数如何被调用,用于调试...
     $this->func_call = "\$db->query(\"{$query}\")";
     //跟踪最后查询语句,用于调试..
     $this->last_query = $query;
     //解析查询语句
     if (!($stmt = OCIParse($this->dbh, $query))) {
         $this->print_error();
     } elseif (!($this->result = OCIExecute($stmt))) {
         $this->print_error();
     }
     $this->num_queries++;
     //执行insert, delete, update, replace操作
     if (preg_match('/^(insert|delete|update|create)\\s+/i', $query)) {
         //获取操作所影响的记录行数
         $return_value = $this->rows_affected = OCIRowCount($stmt);
     } else {
         //获取字段信息
         if ($num_cols = @OCINumCols($stmt)) {
             for ($i = 1; $i <= $num_cols; $i++) {
                 $this->col_info[$i - 1]->name = OCIColumnName($stmt, $i);
                 $this->col_info[$i - 1]->type = OCIColumnType($stmt, $i);
                 $this->col_info[$i - 1]->size = OCIColumnSize($stmt, $i);
             }
         }
         //获取查询结果
         if ($this->num_rows = @OCIFetchStatement($stmt, $results)) {
             //将结果集转变成对象,因为oracle的返回结果比较奇怪:)
             foreach ($results as $col_title => $col_contents) {
                 $row_num = 0;
                 //循环所有的行
                 foreach ($col_contents as $col_content) {
                     $this->last_result[$row_num]->{$col_title} = $col_content;
                     $row_num++;
                 }
             }
         }
         //获取查询结果行数
         $return_value = $this->num_rows;
     }
     //是否显示所有的查询信息
     $this->debug_all ? $this->debug() : null;
     return $return_value;
 }
开发者ID:chaobj001,项目名称:tt,代码行数:50,代码来源:DBOracle.class.php

示例13: preg_replace

 function &SelectLimit($sql, $nrows = -1, $offset = -1, $inputarr = false, $arg3 = false, $secs2cache = 0)
 {
     $sql = preg_replace('/^[ \\t]*select/i', 'SELECT /*+FIRST_ROWS*/', $sql);
     if ($offset < 100) {
         if ($nrows > 0) {
             if ($offset > 0) {
                 $nrows += $offset;
             }
             //$inputarr['adodb_rownum'] = $nrows;
             $sql = "select * from ({$sql}) where rownum <= {$nrows}";
             $nrows = -1;
         }
         // note that $nrows = 0 still has to work ==> no rows returned
         return ADOConnection::SelectLimit($sql, $nrows, $offset, $inputarr, $arg3, $secs2cache);
     } else {
         // Algorithm by Tomas V V Cox, from PEAR DB oci8.php
         // Let Oracle return the name of the columns
         $q_fields = "SELECT * FROM ({$sql}) WHERE NULL = NULL";
         if (!($result = OCIParse($this->_connectionID, $q_fields))) {
             return false;
         }
         if (!($success = OCIExecute($result, OCI_DEFAULT))) {
             return false;
         }
         $ncols = OCINumCols($result);
         for ($i = 1; $i <= $ncols; $i++) {
             $cols[] = OCIColumnName($result, $i);
         }
         $result = false;
         $fields = implode(',', $cols);
         $nrows += $offset;
         $offset += 1;
         // in Oracle rownum starts at 1
         $sql = "SELECT {$fields} FROM" . "(SELECT rownum as adodb_rownum, {$fields} FROM" . " ({$sql}) WHERE rownum <= {$nrows}" . ") WHERE adodb_rownum >= {$offset}";
         if ($secs2cache > 0) {
             return $this->CacheExecute($secs2cache, $sql, $inputarr, $arg3);
         } else {
             return $this->Execute($sql, $inputarr, $arg3);
         }
     }
 }
开发者ID:qoire,项目名称:portal,代码行数:41,代码来源:adodb-oci8.inc.php

示例14: str_replace

 function &SelectLimit($sql, $nrows = -1, $offset = -1, $inputarr = false, $secs2cache = 0)
 {
     // seems that oracle only supports 1 hint comment in 8i
     if ($this->firstrows) {
         if (strpos($sql, '/*+') !== false) {
             $sql = str_replace('/*+ ', '/*+FIRST_ROWS ', $sql);
         } else {
             $sql = preg_replace('/^[ \\t\\n]*select/i', 'SELECT /*+FIRST_ROWS*/', $sql);
         }
     }
     if ($offset < $this->selectOffsetAlg1 && 0 < $nrows && $nrows < 1000) {
         if ($nrows > 0) {
             if ($offset > 0) {
                 $nrows += $offset;
             }
             //$inputarr['adodb_rownum'] = $nrows;
             if ($this->databaseType == 'oci8po') {
                 $sql = "select * from (" . $sql . ") where rownum <= ?";
             } else {
                 $sql = "select * from (" . $sql . ") where rownum <= :adodb_offset";
             }
             $inputarr['adodb_offset'] = $nrows;
             $nrows = -1;
         }
         // note that $nrows = 0 still has to work ==> no rows returned
         $rs =& ADOConnection::SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
         return $rs;
     } else {
         // Algorithm by Tomas V V Cox, from PEAR DB oci8.php
         // Let Oracle return the name of the columns
         $q_fields = "SELECT * FROM (" . $sql . ") WHERE NULL = NULL";
         $false = false;
         if (!($stmt_arr = $this->Prepare($q_fields))) {
             return $false;
         }
         $stmt = $stmt_arr[1];
         if (is_array($inputarr)) {
             // If there are any numeric keys, all key must be in an integer sequence
             // starting at 0 without any gaps for OCIBindByName() to work.
             $arr4fields = $inputarr;
             foreach ($inputarr as $k => $v) {
                 if (is_int($k)) {
                     // Reindex array
                     $arr4fields = array_values($inputarr);
                     break;
                 }
             }
             foreach ($arr4fields as $k => $v) {
                 if (is_array($v)) {
                     if (sizeof($v) == 2) {
                         // suggested by g.giunta@libero.
                         OCIBindByName($stmt, ":{$k}", $arr4fields[$k][0], $v[1]);
                     } else {
                         OCIBindByName($stmt, ":{$k}", $arr4fields[$k][0], $v[1], $v[2]);
                     }
                 } else {
                     $len = -1;
                     if ($v === ' ') {
                         $len = 1;
                     }
                     if (isset($bindarr)) {
                         // is prepared sql, so no need to ocibindbyname again
                         $bindarr[$k] = $v;
                     } else {
                         // dynamic sql, so rebind every time
                         OCIBindByName($stmt, ":{$k}", $arr4fields[$k], $len);
                     }
                 }
             }
         }
         if (!OCIExecute($stmt, OCI_DEFAULT)) {
             OCIFreeStatement($stmt);
             return $false;
         }
         $ncols = OCINumCols($stmt);
         for ($i = 1; $i <= $ncols; $i++) {
             $cols[] = '"' . OCIColumnName($stmt, $i) . '"';
         }
         $result = false;
         OCIFreeStatement($stmt);
         $fields = implode(',', $cols);
         $nrows_placeholder = $offset_placeholder = '?';
         if ($this->databaseType != 'oci8po') {
             $nrows_placeholder = ':adodb_nrows';
             $offset_placeholder = ':adodb_offset';
         }
         if ($offset >= 0 && $nrows >= 0) {
             $sql = "SELECT {$fields} FROM" . "(SELECT rownum as adodb_rownum, {$fields} FROM" . " ({$sql}) WHERE rownum <= {$nrows_placeholder}" . ") WHERE adodb_rownum >= {$offset_placeholder}";
             $offset += 1;
             // in Oracle rownum starts at 1
             $nrows += $offset;
             $inputarr['adodb_nrows'] = $nrows;
             $inputarr['adodb_offset'] = $offset;
         } else {
             if ($offset >= 0) {
                 $sql = "SELECT {$fields} FROM" . "(SELECT rownum as adodb_rownum, {$fields} FROM" . " ({$sql})" . ") WHERE adodb_rownum >= {$offset_placeholder}";
                 $offset += 1;
                 // in Oracle rownum starts at 1
                 $inputarr['adodb_offset'] = $offset;
             } else {
//.........这里部分代码省略.........
开发者ID:justinlyon,项目名称:scc,代码行数:101,代码来源:adodb-oci8.inc.php

示例15: htmlentities

if ($conn) {
    print "<br> Connection to the database successful";
} else {
    $e = oci_error;
    print "<br> connection failed:";
    print htmlentities($e['message']);
    exit;
}
// create SQL statement
$sql = "Select * from Classes";
// parse SQL statement
$sql_statement = OCIParse($conn, $sql);
// execute SQL query
OCIExecute($sql_statement);
// get number of columns for use later
$num_columns = OCINumCols($sql_statement);
// start results formatting
echo "<TABLE BORDER=1>";
echo "<TR><TH>SCU Core Class</TH><TH>Alternate Class</TH><TH>University</TH></TR>";
// format results by row
while (OCIFetch($sql_statement)) {
    echo "<TR>";
    for ($i = 1; $i <= $num_columns; $i++) {
        $column_value = OCIResult($sql_statement, $i);
        echo "<TD>{$column_value}</TD>";
    }
    echo "</TR>";
}
echo "</TABLE>";
OCIFreeStatement($sql_statement);
OCILogoff($conn);
开发者ID:avitron1,项目名称:COEN-174-Initial-OS,代码行数:31,代码来源:dbtest.php


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