本文整理汇总了PHP中ocinumcols函数的典型用法代码示例。如果您正苦于以下问题:PHP ocinumcols函数的具体用法?PHP ocinumcols怎么用?PHP ocinumcols使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ocinumcols函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: num_fields
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
$count = @ocinumcols($this->stmt_id);
// if we used a limit we subtract it
if ($this->limit_used) {
$count = $count - 1;
}
return $count;
}
示例2: oci8Adapter
/**
* Constructor method for the adapter. This constructor implements the setting of the
* 3 required properties for the object.
*
* @param resource $d The datasource resource
*/
function oci8Adapter($d)
{
parent::RecordSetAdapter($d);
$fieldcount = ocinumcols($d);
for ($j = 0; $j < $fieldcount; $j++) {
$this->columnNames[] = ocicolumnname($d, $j + 1);
}
$i = 0;
while (OCIFetchInto($d, $line, OCI_NUM + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
$this->rows[] = $line;
}
}
示例3: oci8Adapter
/**
* Constructor method for the adapter. This constructor implements the setting of the
* 3 required properties for the object.
*
* @param resource $d The datasource resource
*/
function oci8Adapter($d)
{
parent::RecordSetAdapter($d);
$fieldcount = ocinumcols($d);
$ob = "";
$be = $this->isBigEndian;
$fc = pack('N', $fieldcount);
$i = 0;
while (OCIFetchInto($d, $line, OCI_NUM + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
// write all of the array elements
$ob .= "\n" . $fc;
foreach ($line as $value) {
// write all of the array elements
if (is_string($value)) {
// type as string
$os = $this->_directCharsetHandler->transliterate($value);
//string flag, string length, and string
$len = strlen($os);
if ($len < 65536) {
$ob .= "" . pack('n', $len) . $os;
} else {
$ob .= "\f" . pack('N', $len) . $os;
}
} elseif (is_float($value) || is_int($value)) {
// type as double
$b = pack('d', $value);
// pack the bytes
if ($be) {
// if we are a big-endian processor
$r = strrev($b);
} else {
// add the bytes to the output
$r = $b;
}
$ob .= "" . $r;
} elseif (is_bool($value)) {
//type as bool
$ob .= "";
$ob .= pack('c', $value);
} elseif (is_null($value)) {
// null
$ob .= "";
}
}
$i++;
}
$this->serializedData = $ob;
for ($j = 0; $j < $fieldcount; $j++) {
$this->columnNames[] = $this->_charsetHandler->transliterate(ocicolumnname($d, $j + 1));
}
$this->numRows = $i;
}
示例4: htmlspecialchars
@ociexecute($stat);
if ($error = @ocierror()) {
echo "<table width=100%><tr><td><font face=Verdana size=-2>Error : <b>" . $error['message'] . "</b></font></td></tr></table><br>";
} else {
$rowcount = @ocirowcount($stat);
if ($rowcount != 0) {
echo "<table width=100%><tr><td><font face=Verdana size=-2>affected rows : <b>" . $rowcount . "</b></font></td></tr></table><br>";
} else {
echo "<table width=100%><tr>";
for ($j = 1; $j <= @ocinumcols($stat); $j++) {
echo "<td bgcolor=#cccccc><font face=Verdana size=-2><b> " . htmlspecialchars(@ocicolumnname($stat, $j)) . " </b></font></td>";
}
echo "</tr>";
while (ocifetch($stat)) {
echo "<tr>";
for ($j = 1; $j <= @ocinumcols($stat); $j++) {
echo "<td><font face=Verdana size=-2> " . htmlspecialchars(@ociresult($stat, $j)) . " </font></td>";
}
echo "</tr>";
}
echo "</table><br>";
}
@ocifreestatement($stat);
}
}
}
@ocilogoff($db);
}
break;
}
echo "<form name=form method=POST>";
示例5: write_data
function write_data($table_name)
{
global $db;
$ary_type = $ary_name = array();
// Grab all of the data from current table.
$sql = "SELECT *\n\t\t\tFROM {$table_name}";
$result = $db->sql_query($sql);
$i_num_fields = ocinumcols($result);
for ($i = 0; $i < $i_num_fields; $i++) {
$ary_type[$i] = ocicolumntype($result, $i + 1);
$ary_name[$i] = ocicolumnname($result, $i + 1);
}
$sql_data = '';
while ($row = $db->sql_fetchrow($result)) {
$schema_vals = $schema_fields = array();
// Build the SQL statement to recreate the data.
for ($i = 0; $i < $i_num_fields; $i++) {
// Oracle uses uppercase - we use lowercase
$str_val = $row[strtolower($ary_name[$i])];
if (preg_match('#char|text|bool|raw|clob#i', $ary_type[$i])) {
$str_quote = '';
$str_empty = "''";
$str_val = sanitize_data_oracle($str_val);
} else {
if (preg_match('#date|timestamp#i', $ary_type[$i])) {
if (empty($str_val)) {
$str_quote = '';
} else {
$str_quote = "'";
}
} else {
$str_quote = '';
$str_empty = 'NULL';
}
}
if (empty($str_val) && $str_val !== '0') {
$str_val = $str_empty;
}
$schema_vals[$i] = $str_quote . $str_val . $str_quote;
$schema_fields[$i] = '"' . $ary_name[$i] . '"';
}
// Take the ordered fields and their associated data and build it
// into a valid sql statement to recreate that field in the data.
$sql_data = "INSERT INTO {$table_name} (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ")\n/\n";
$this->flush($sql_data);
}
$db->sql_freeresult($result);
}
示例6: get_result
function get_result()
{
$this->rows = array();
$this->columns = array();
$this->num_rows = $this->num_fields = 0;
switch ($this->db) {
case 'MySQL':
$this->num_rows = @mysql_num_rows($this->res);
$this->num_fields = @mysql_num_fields($this->res);
while (false !== ($this->rows[] = @mysql_fetch_assoc($this->res))) {
}
@mysql_free_result($this->res);
if ($this->num_rows) {
$this->columns = @array_keys($this->rows[0]);
return 1;
}
break;
case 'MSSQL':
$this->num_rows = @mssql_num_rows($this->res);
$this->num_fields = @mssql_num_fields($this->res);
while (false !== ($this->rows[] = @mssql_fetch_assoc($this->res))) {
}
@mssql_free_result($this->res);
if ($this->num_rows) {
$this->columns = @array_keys($this->rows[0]);
return 1;
}
break;
case 'PostgreSQL':
$this->num_rows = @pg_num_rows($this->res);
$this->num_fields = @pg_num_fields($this->res);
while (false !== ($this->rows[] = @pg_fetch_assoc($this->res))) {
}
@pg_free_result($this->res);
if ($this->num_rows) {
$this->columns = @array_keys($this->rows[0]);
return 1;
}
break;
case 'Oracle':
$this->num_fields = @ocinumcols($this->res);
while (false !== ($this->rows[] = @oci_fetch_assoc($this->res))) {
$this->num_rows++;
}
@ocifreestatement($this->res);
if ($this->num_rows) {
$this->columns = @array_keys($this->rows[0]);
return 1;
}
break;
}
return 0;
}
示例7: main
//.........这里部分代码省略.........
} else {
$str_quote = '';
$str_empty = 'NULL';
}
}
if (empty($str_val) && $str_val !== '0') {
$str_val = $str_empty;
}
$schema_vals[$i] = $str_quote . $str_val . $str_quote;
$schema_fields[$i] = "'" . $ary_name[$i] . "'";
}
// Take the ordered fields and their associated data and build it
// into a valid sql statement to recreate that field in the data.
$sql_data .= "INSERT INTO {$table_name} (" . implode(', ', $schema_fields) . ') VALUES(' . implode(', ', $schema_vals) . ");\n";
if ($store == true) {
$write($fp, $sql_data);
}
if ($download == true) {
if (!empty($oper)) {
echo $oper($sql_data);
} else {
echo $sql_data;
}
}
$sql_data = '';
}
$db->sql_freeresult($result);
break;
case 'oracle':
$ary_type = $ary_name = array();
// Grab all of the data from current table.
$sql = "SELECT *\n\t\t\t\t\t\t\t\t\t\t\tFROM {$table_name}";
$result = $db->sql_query($sql);
$i_num_fields = ocinumcols($result);
for ($i = 0; $i < $i_num_fields; $i++) {
$ary_type[$i] = ocicolumntype($result, $i);
$ary_name[$i] = ocicolumnname($result, $i);
}
while ($row = $db->sql_fetchrow($result)) {
$schema_vals = $schema_fields = array();
// Build the SQL statement to recreate the data.
for ($i = 0; $i < $i_num_fields; $i++) {
$str_val = $row[$ary_name[$i]];
if (preg_match('#char|text|bool#i', $ary_type[$i])) {
$str_quote = "'";
$str_empty = '';
$str_val = addslashes($str_val);
} else {
if (preg_match('#date|timestamp#i', $ary_type[$i])) {
if (empty($str_val)) {
$str_quote = '';
} else {
$str_quote = "'";
}
} else {
$str_quote = '';
$str_empty = 'NULL';
}
}
if (empty($str_val) && $str_val !== '0') {
$str_val = $str_empty;
}
$schema_vals[$i] = $str_quote . $str_val . $str_quote;
$schema_fields[$i] = '"' . $ary_name[$i] . "'";
}
// Take the ordered fields and their associated data and build it
示例8: selectLimit
/**
* 分页算法从 adodb 修改
*/
function selectLimit($sql, $length = 'ALL', $offset = 0)
{
if (strpos($sql, '/*+') !== false) {
$sql = str_replace('/*+ ', '/*+FIRST_ROWS ', $sql);
} else {
$sql = preg_replace('/^[ \\t\\n]*SELECT/i', 'SELECT /*+FIRST_ROWS*/', $sql);
}
$selectOffsetAlg1 = 100;
$inputarr = array();
if ($offset < $selectOffsetAlg1) {
if ($length > 0) {
if ($offset > 0) {
$length += $offset;
}
$sql = "SELECT * FROM ({$sql}) WHERE ROWNUM <= :length";
$inputarr['length'] = $length;
}
$stmt = $this->execute($sql, $inputarr);
for ($i = 0; $i < $offset; $i++) {
ocifetch($stmt);
}
return $stmt;
} else {
// Algorithm by Tomas V V Cox, from PEAR DB oci8.php
// Let Oracle return the name of the columns
$qfields = "SELECT * FROM ({$sql}) WHERE NULL = NULL";
$stmt = ociparse($this->conn, $qfields);
if (!$stmt) {
return false;
}
if (is_array($inputarr)) {
foreach (array_keys($inputarr) as $k) {
ocibindbyname($stmt, $k, $inputarr[$k], -1);
}
}
if (!ociexecute($stmt, OCI_DEFAULT)) {
ocifreestatement($stmt);
return false;
}
$ncols = ocinumcols($stmt);
for ($i = 1; $i <= $ncols; $i++) {
$cols[] = '"' . ocicolumnname($stmt, $i) . '"';
}
ocifreestatement($stmt);
$fields = implode(', ', $cols);
$length += $offset;
$offset += 1;
// in Oracle rownum starts at 1
$sql = "SELECT {$fields} FROM " . "(SELECT rownum as adodb_rownum, {$fields} FROM " . "({$sql})" . ' WHERE rownum <= :adodb_nrows) WHERE adodb_rownum >= :adodb_offset';
$inputarr['adodb_nrows'] = $length;
$inputarr['adodb_offset'] = $offset;
return $this->execute($sql, $inputarr);
}
}
示例9: getNumberOfFields
/**
* Get the number of fields that were selected by the SELECT query.
* Get the number of fields that were selected by the SELECT query.
* @access public
* @return integer The number of fields.
**/
function getNumberOfFields()
{
return ocinumcols($this->_resourceId);
}
示例10: NumFields
function NumFields($rsMain)
{
return ocinumcols($rsMain);
}
示例11: da_sql_list_fields
function da_sql_list_fields($table, $link, $config)
{
$res = @da_sql_query($link, $config, "SELECT * from {$table} WHERE ROWNUM <=1");
if ($res) {
$fields[res] = array();
for ($i = 1; $i <= ocinumcols($res); $i++) {
array_push($fields[res], strtolower(OCIColumnName($res, $i)));
}
$fields[num] = @ocinumcols($res);
} else {
return NULL;
}
return $fields;
}
示例12: db_get_query_rows
/**
* Get the rows returned from a SELECT query.
*
* @param resource The query result pointer
* @param ?integer Whether to start reading from (NULL: irrelevant for this forum driver)
* @return array A list of row maps
*/
function db_get_query_rows($stmt, $start = NULL)
{
$out = array();
$i = 0;
$num_fields = ocinumcols($stmt);
$types = array();
$names = array();
for ($x = 1; $x <= $num_fields; $x++) {
$types[$x] = ocicolumntype($stmt, $x);
$names[$x] = strtolower(ocicolumnname($stmt, $x));
}
while (ocifetch($stmt)) {
if (is_null($start) || $i >= $start) {
$newrow = array();
for ($j = 1; $j <= $num_fields; $j++) {
$v = ociresult($stmt, $j);
if (is_object($v)) {
$v = $v->load();
}
// For CLOB's
if ($v === false) {
fatal_exit(do_lang_tempcode('QUERY_FAILED', ocierror($stmt)));
}
$name = $names[$j];
$type = $types[$j];
if ($type == 'NUMBER') {
if (!is_null($v)) {
$newrow[$name] = intval($v);
} else {
$newrow[$name] = NULL;
}
} else {
if ($v == ' ') {
$v = '';
}
$newrow[$name] = $v;
}
}
$out[] = $newrow;
}
$i++;
}
return $out;
}
示例13: db_numfields
/**
* db_numfields() - Returns the number of fields in this result set
*
* @param sting Query result set handle
*/
function db_numfields($lhandle)
{
return @ocinumcols($lhandle);
}
示例14: get_num_fields
function get_num_fields()
{
$this->num_fields = 0;
switch ($this->db) {
case 'MySQL':
$this->num_fields = @mysql_num_fields($this->res);
break;
case 'MSSQL':
$this->num_fields = @mssql_num_fields($this->res);
break;
case 'PostgreSQL':
$this->num_fields = @pg_num_fields($this->res);
break;
case 'Oracle':
$this->num_fields = @ocinumcols($this->res);
break;
}
}
示例15: ocidefinebyname
ocidefinebyname();
ocierror();
ociexecute();
ocifetch();
ocifetchinto();
ocifetchstatement();
ocifreecollection();
ocifreecursor();
ocifreedesc();
ocifreestatement();
ociinternaldebug();
ociloadlob();
ocilogoff();
ocilogon();
ocinewcollection();
ocinewcursor();
ocinewdescriptor();
ocinlogon();
ocinumcols();
ociparse();
ociplogon();
ociresult();
ocirollback();
ocirowcount();
ocisavelob();
ocisavelobfile();
ociserverversion();
ocisetprefetch();
ocistatementtype();
ociwritelobtofile();
ociwritetemporarylob();