Source for file ifx.php
Documentation is available at ifx.php 
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */  
// +----------------------------------------------------------------------+  
// +----------------------------------------------------------------------+  
// | Copyright (c) 1997-2004 The PHP Group                                |  
// +----------------------------------------------------------------------+  
// | This source file is subject to version 2.02 of the PHP license,      |  
// | that is bundled with this package in the file LICENSE, and is        |  
// | available at through the world-wide-web at                           |  
// | http://www.php.net/license/2_02.txt.                                 |  
// | If you did not receive a copy of the PHP license and are unable to   |  
// | obtain it through the world-wide-web, please send a note to          |  
// | license@php.net so we can mail you a copy immediately.               |  
// +----------------------------------------------------------------------+  
// | Author: Tomas V.V.Cox <cox@idecnet.com>                              |  
// | Maintainer: Daniel Convissor <danielc@php.net>                       |  
// +----------------------------------------------------------------------+  
// $Id: ifx.php,v 1.47 2004/03/05 01:46:53 danielc Exp $  
// For more info on Informix errors see:  
// http://www.informix.com/answers/english/ierrors.htm  
//  - set needed env Informix vars on connect  
//  - implement native prepare/execute  
require_once 'DB/common.php';   
 * Database independent query interface definition for PHP's Informix  
 * @version  $Id: ifx.php,v 1.47 2004/03/05 01:46:53 danielc Exp $  
 * @author   Tomas V.V.Cox <cox@idecnet.com>  
    var $fetchmode = DB_FETCHMODE_ORDERED;  /* Default fetch mode */  
     * Connect to a database and log in as the specified user.  
     * @param $dsn the data source name (see DB::parseDSN for syntax)  
     * @param $persistent (optional) whether the connection should  
     * @return int DB_OK on success, a DB error code on failure  
    function connect($dsninfo, $persistent = false )  
        $dbhost =  $dsninfo['hostspec'] ?  '@' .  $dsninfo['hostspec'] :  '';   
        $dbname =  $dsninfo['database'] ?  $dsninfo['database'] .  $dbhost :  '';   
        $user =  $dsninfo['username'] ?  $dsninfo['username'] :  '';   
        $pw =  $dsninfo['password'] ?  $dsninfo['password'] :  '';   
        $connect_function =  $persistent ?  'ifx_pconnect' :  'ifx_connect';   
        $this->connection =  @$connect_function($dbname, $user, $pw);   
     * Log out and disconnect from the database.  
     * @return bool true on success, false if not connected.  
     * Send a query to Informix and return the results as a  
     * Informix resource identifier.  
     * @param $query the SQL query  
     * @return int returns a valid Informix result for successful SELECT  
     *  queries, DB_OK for other successful queries.  A DB error code  
     *  is returned on failure.  
        if (preg_match('/(SELECT)/i', $query)) {    //TESTME: Use !DB::isManip()?  
            // the scroll is needed for fetching absolute row numbers  
            // in a select query result  
            $result =  @ifx_query ($query, $this->connection, IFX_SCROLL );   
                    $result =  @ifx_query ('BEGIN WORK', $this->connection);   
        $this->affected =  @ifx_affected_rows ($result);   
        // Determine which queries should return data, and which  
        // should return an error code only.  
        // XXX Testme: free results inside a transaction  
        // may cause to stop it and commit the work?  
        // Result has to be freed even with a insert or update  
        @ifx_free_result ($result);   
     * Move the internal ifx result pointer to the next available result  
     * @param a valid fbsql result resource  
     * @return true if a result is available otherwise return false  
     * Gets the number of rows affected by the last query.  
     * if the last query was a select, returns 0.  
     * @return number of rows affected by the last query  
     * Fetch a row and insert the data into an existing array.  
     * Formating of the array and the data therein are configurable.  
     * See DB_result::fetchInto() for more information.  
     * @param resource $result    query result identifier  
     * @param array    $arr       (reference) array where data from the row  
     * @param int      $fetchmode how the resulting array should be indexed  
     * @param int      $rownum    the row number to fetch  
     * @return mixed DB_OK on success, null when end of result set is  
     * @see DB_result::fetchInto()  
    function fetchInto ($result, &$arr, $fetchmode, $rownum=null )  
        if (($rownum !== null ) &&  ($rownum < 0 )) {  
             * Even though fetch_row() should return the next row  if  
             * $rownum is null, it doesn't in all cases.  Bug 598.  
            // Index starts at row 1, unlike most DBMS's starting at 0.  
        if (!$arr =  @ifx_fetch_row ($result, $rownum)) {  
            $this->_rtrimArrayValues ($arr);   
            $this->_convertNullArrayValuesToEmpty ($arr);   
     * Get the number of columns in a result set.  
     * @param $result Informix result identifier  
     * @return int the number of columns per row in $result  
        if (!$cols =  @ifx_num_fields ($result)) {  
     * Free the internal resources associated with $result.  
     * @param $result Informix result identifier  
     * @return bool true on success, false if $result is invalid  
        return @ifx_free_result ($result);   
     * Enable/disable automatic commits  
        // XXX if $this->transaction_opcount > 0, we should probably  
     * Commit the current transaction.  
            $result =  @ifx_query ('COMMIT WORK', $this->connection);   
                return $this->ifxRaiseError ();   
     * Roll back (undo) the current transaction.  
            $result =  @ifx_query ('ROLLBACK WORK', $this->connection);   
                return $this->ifxRaiseError ();   
     * Gather information about an error, then use that info to create a  
     * DB error object and finally return that object.  
     * @param  integer  $errno  PEAR error number (usually a DB constant) if  
     *                           manually raising an error  
     * @return object  DB error object  
     * @see DB_common::raiseError()  
        return $this->raiseError($errno, null , null , null ,  
     * Map 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.  
        if (ereg('SQLCODE=(.*)]', $nativecode, $match)) {  
     * Get the native error message of the last error (if any) that  
     * occured on the current connection.  
     * @return int native Informix error code  
        return @ifx_error () .  ' ' .  @ifx_errormsg ();   
     * Returns the query needed to get some backend info  
     * @param string $type What kind of info you want to retrieve  
     * @return string The SQL query string  
                return 'select tabname from systables where tabid >= 100';   
     * 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  
     * @param int            $mode    a valid tableInfo mode  
     * @return array  an associative array with the information requested  
     *                 or an error object if something is wrong  
     * @see DB_common::tableInfo()  
        if (isset ($result->result )) {  
             * Probably received a result object.  
             * Extract the result resource identifier.  
             * Probably received a table name.  
             * Create a result resource identifier.  
            $id =  @ifx_query (" SELECT * FROM $result WHERE 1=0" ,  
             * Probably received a result resource identifier.  
        $flds =  @ifx_fieldproperties ($id);   
        $count =  @ifx_num_fields ($id);   
        if (count($flds) !=  $count) {  
            return $this->raiseError("can't distinguish duplicate field names");   
            $case_func =  'strtolower';   
        // made this IF due to performance (one if is faster than $count if's)  
            foreach ($flds as  $key =>  $value) {  
                $res[$i]['table'] =  $got_string ?  $case_func($result) :  '';   
                $res[$i]['name']  =  $case_func($key);   
                $res[$i]['type']  =  $props[0 ];   
                $res[$i]['len']   =  $props[1 ];   
                $res[$i]['flags'] =  $props[4 ] ==  'N' ?  'not_null' :  '';   
            $res['num_fields'] =  $count;   
            foreach ($flds as  $key =>  $value) {  
                $res[$i]['table'] =  $got_string ?  $case_func($result) :  '';   
                $res[$i]['name']  =  $case_func($key);   
                $res[$i]['type']  =  $props[0 ];   
                $res[$i]['len']   =  $props[1 ];   
                $res[$i]['flags'] =  $props[4 ] ==  'N' ?  'not_null' :  '';   
                    $res['order'][$res[$i]['name']] =  $i;   
                    $res['ordertable'][$res[$i]['table']][$res[$i]['name']] =  $i;   
        // free the result only if we were called on a table  
 
 
        
		    
 
		    Documentation generated on Mon, 11 Mar 2019 10:14:52 -0400 by  phpDocumentor 1.4.4. PEAR Logo Copyright ©  PHP Group 2004.
	        
       |