📄 ifx.php
字号:
function fetchInto($result, &$arr, $fetchmode, $rownum = null) { if (($rownum !== null) && ($rownum < 0)) { return null; } if ($rownum === null) { /* * Even though fetch_row() should return the next row if * $rownum is null, it doesn't in all cases. Bug 598. */ $rownum = 'NEXT'; } else { // Index starts at row 1, unlike most DBMS's starting at 0. $rownum++; } if (!$arr = @ifx_fetch_row($result, $rownum)) { return null; } if ($fetchmode !== DB_FETCHMODE_ASSOC) { $i=0; $order = array(); foreach ($arr as $val) { $order[$i++] = $val; } $arr = $order; } elseif ($fetchmode == DB_FETCHMODE_ASSOC && $this->options['portability'] & DB_PORTABILITY_LOWERCASE) { $arr = array_change_key_case($arr, CASE_LOWER); } if ($this->options['portability'] & DB_PORTABILITY_RTRIM) { $this->_rtrimArrayValues($arr); } if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) { $this->_convertNullArrayValuesToEmpty($arr); } return DB_OK; } // }}} // {{{ numCols() /** * Gets the number of columns in a result set * * This method is not meant to be called directly. Use * DB_result::numCols() instead. It can't be declared "protected" * because DB_result is a separate object. * * @param resource $result PHP's query result resource * * @return int the number of columns. A DB_Error object on failure. * * @see DB_result::numCols() */ function numCols($result) { if (!$cols = @ifx_num_fields($result)) { return $this->ifxRaiseError(); } return $cols; } // }}} // {{{ freeResult() /** * Deletes the result set and frees the memory occupied by the result set * * This method is not meant to be called directly. Use * DB_result::free() instead. It can't be declared "protected" * because DB_result is a separate object. * * @param resource $result PHP's query result resource * * @return bool TRUE on success, FALSE if $result is invalid * * @see DB_result::free() */ function freeResult($result) { return @ifx_free_result($result); } // }}} // {{{ autoCommit() /** * Enables or disables automatic commits * * @param bool $onoff true turns it on, false turns it off * * @return int DB_OK on success. A DB_Error object if the driver * doesn't support auto-committing transactions. */ function autoCommit($onoff = true) { // XXX if $this->transaction_opcount > 0, we should probably // issue a warning here. $this->autocommit = $onoff ? true : false; return DB_OK; } // }}} // {{{ commit() /** * Commits the current transaction * * @return int DB_OK on success. A DB_Error object on failure. */ function commit() { if ($this->transaction_opcount > 0) { $result = @ifx_query('COMMIT WORK', $this->connection); $this->transaction_opcount = 0; if (!$result) { return $this->ifxRaiseError(); } } return DB_OK; } // }}} // {{{ rollback() /** * Reverts the current transaction * * @return int DB_OK on success. A DB_Error object on failure. */ function rollback() { if ($this->transaction_opcount > 0) { $result = @ifx_query('ROLLBACK WORK', $this->connection); $this->transaction_opcount = 0; if (!$result) { return $this->ifxRaiseError(); } } return DB_OK; } // }}} // {{{ ifxRaiseError() /** * Produces a DB_Error object regarding the current problem * * @param int $errno if the error is being manually raised pass a * DB_ERROR* constant here. If this isn't passed * the error information gathered from the DBMS. * * @return object the DB_Error object * * @see DB_common::raiseError(), * DB_ifx::errorNative(), DB_ifx::errorCode() */ function ifxRaiseError($errno = null) { if ($errno === null) { $errno = $this->errorCode(ifx_error()); } return $this->raiseError($errno, null, null, null, $this->errorNative()); } // }}} // {{{ errorNative() /** * Gets the DBMS' native error code and message produced by the last query * * @return string the DBMS' error code and message */ function errorNative() { return @ifx_error() . ' ' . @ifx_errormsg(); } // }}} // {{{ errorCode() /** * Maps native error codes to DB's portable ones. * * Requires that the DB implementation's constructor fills * in the <var>$errorcode_map</var> property. * * @param string $nativecode error code returned by the database * @return int a portable DB error code, or DB_ERROR if this DB * implementation has no mapping for the given error code. */ function errorCode($nativecode) { if (ereg('SQLCODE=(.*)]', $nativecode, $match)) { $code = $match[1]; if (isset($this->errorcode_map[$code])) { return $this->errorcode_map[$code]; } } return DB_ERROR; } // }}} // {{{ tableInfo() /** * Returns information about a table or a result set * * NOTE: only supports 'table' if <var>$result</var> is a table name. * * If analyzing a query result and the result has duplicate field names, * an error will be raised saying * <samp>can't distinguish duplicate field names</samp>. * * @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() * @since Method available since Release 1.6.0 */ function tableInfo($result, $mode = null) { if (is_string($result)) { /* * Probably received a table name. * Create a result resource identifier. */ $id = @ifx_query("SELECT * FROM $result WHERE 1=0", $this->connection); $got_string = true; } elseif (isset($result->result)) { /* * Probably received a result object. * Extract the result resource identifier. */ $id = $result->result; $got_string = false; } else { /* * Probably received a result resource identifier. * Copy it. */ $id = $result; $got_string = false; } if (!is_resource($id)) { return $this->ifxRaiseError(DB_ERROR_NEED_MORE_DATA); } $flds = @ifx_fieldproperties($id); $count = @ifx_num_fields($id); if (count($flds) != $count) { return $this->raiseError("can't distinguish duplicate field names"); } if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) { $case_func = 'strtolower'; } else { $case_func = 'strval'; } $i = 0; $res = array(); if ($mode) { $res['num_fields'] = $count; } foreach ($flds as $key => $value) { $props = explode(';', $value); $res[$i] = array( 'table' => $got_string ? $case_func($result) : '', 'name' => $case_func($key), 'type' => $props[0], 'len' => $props[1], 'flags' => $props[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++; } // free the result only if we were called on a table if ($got_string) { @ifx_free_result($id); } return $res; } // }}} // {{{ getSpecialQuery() /** * Obtains the query string needed for listing a given type of objects * * @param string $type the kind of objects you want to retrieve * * @return string the SQL query string or null if the driver doesn't * support the object type requested * * @access protected * @see DB_common::getListOf() */ function getSpecialQuery($type) { switch ($type) { case 'tables': return 'SELECT tabname FROM systables WHERE tabid >= 100'; default: return null; } } // }}}}/* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: */?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -