Subversion Repositories Applications.gtt

Rev

Rev 94 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 187
Line 4... Line 4...
4
 
4
 
5
/**
5
/**
6
 * The PEAR DB driver for PHP's ifx extension
6
 * The PEAR DB driver for PHP's ifx extension
7
 * for interacting with Informix databases
7
 * for interacting with Informix databases
8
 *
8
 *
9
 * PHP versions 4 and 5
9
 * PHP version 5
10
 *
10
 *
11
 * LICENSE: This source file is subject to version 3.0 of the PHP license
11
 * LICENSE: This source file is subject to version 3.0 of the PHP license
12
 * that is available through the world-wide-web at the following URI:
12
 * that is available through the world-wide-web at the following URI:
13
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
13
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
Line 16... Line 16...
16
 *
16
 *
17
 * @category   Database
17
 * @category   Database
18
 * @package    DB
18
 * @package    DB
19
 * @author     Tomas V.V.Cox <cox@idecnet.com>
19
 * @author     Tomas V.V.Cox <cox@idecnet.com>
20
 * @author     Daniel Convissor <danielc@php.net>
20
 * @author     Daniel Convissor <danielc@php.net>
21
 * @copyright  1997-2005 The PHP Group
21
 * @copyright  1997-2007 The PHP Group
22
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
22
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
23
 * @version    CVS: $Id: ifx.php,v 1.70 2005/02/20 00:44:48 danielc Exp $
23
 * @version    CVS: $Id$
24
 * @link       http://pear.php.net/package/DB
24
 * @link       http://pear.php.net/package/DB
25
 */
25
 */
Line 26... Line 26...
26
 
26
 
27
/**
27
/**
Line 44... Line 44...
44
 *
44
 *
45
 * @category   Database
45
 * @category   Database
46
 * @package    DB
46
 * @package    DB
47
 * @author     Tomas V.V.Cox <cox@idecnet.com>
47
 * @author     Tomas V.V.Cox <cox@idecnet.com>
48
 * @author     Daniel Convissor <danielc@php.net>
48
 * @author     Daniel Convissor <danielc@php.net>
49
 * @copyright  1997-2005 The PHP Group
49
 * @copyright  1997-2007 The PHP Group
50
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
50
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
51
 * @version    Release: 1.7.6
51
 * @version    Release: 1.9.2
52
 * @link       http://pear.php.net/package/DB
52
 * @link       http://pear.php.net/package/DB
53
 */
53
 */
54
class DB_ifx extends DB_common
54
class DB_ifx extends DB_common
55
{
55
{
56
    // {{{ properties
56
    // {{{ properties
Line 99... Line 99...
99
        '-206'    => DB_ERROR_NOSUCHTABLE,
99
        '-206'    => DB_ERROR_NOSUCHTABLE,
100
        '-217'    => DB_ERROR_NOSUCHFIELD,
100
        '-217'    => DB_ERROR_NOSUCHFIELD,
101
        '-236'    => DB_ERROR_VALUE_COUNT_ON_ROW,
101
        '-236'    => DB_ERROR_VALUE_COUNT_ON_ROW,
102
        '-239'    => DB_ERROR_CONSTRAINT,
102
        '-239'    => DB_ERROR_CONSTRAINT,
103
        '-253'    => DB_ERROR_SYNTAX,
103
        '-253'    => DB_ERROR_SYNTAX,
-
 
104
        '-268'    => DB_ERROR_CONSTRAINT,
104
        '-292'    => DB_ERROR_CONSTRAINT_NOT_NULL,
105
        '-292'    => DB_ERROR_CONSTRAINT_NOT_NULL,
105
        '-310'    => DB_ERROR_ALREADY_EXISTS,
106
        '-310'    => DB_ERROR_ALREADY_EXISTS,
106
        '-316'    => DB_ERROR_ALREADY_EXISTS,
107
        '-316'    => DB_ERROR_ALREADY_EXISTS,
107
        '-319'    => DB_ERROR_NOT_FOUND,
108
        '-319'    => DB_ERROR_NOT_FOUND,
108
        '-329'    => DB_ERROR_NODBSELECTED,
109
        '-329'    => DB_ERROR_NODBSELECTED,
Line 111... Line 112...
111
        '-391'    => DB_ERROR_CONSTRAINT_NOT_NULL,
112
        '-391'    => DB_ERROR_CONSTRAINT_NOT_NULL,
112
        '-554'    => DB_ERROR_SYNTAX,
113
        '-554'    => DB_ERROR_SYNTAX,
113
        '-691'    => DB_ERROR_CONSTRAINT,
114
        '-691'    => DB_ERROR_CONSTRAINT,
114
        '-692'    => DB_ERROR_CONSTRAINT,
115
        '-692'    => DB_ERROR_CONSTRAINT,
115
        '-703'    => DB_ERROR_CONSTRAINT_NOT_NULL,
116
        '-703'    => DB_ERROR_CONSTRAINT_NOT_NULL,
-
 
117
        '-1202'   => DB_ERROR_DIVZERO,
116
        '-1204'   => DB_ERROR_INVALID_DATE,
118
        '-1204'   => DB_ERROR_INVALID_DATE,
117
        '-1205'   => DB_ERROR_INVALID_DATE,
119
        '-1205'   => DB_ERROR_INVALID_DATE,
118
        '-1206'   => DB_ERROR_INVALID_DATE,
120
        '-1206'   => DB_ERROR_INVALID_DATE,
119
        '-1209'   => DB_ERROR_INVALID_DATE,
121
        '-1209'   => DB_ERROR_INVALID_DATE,
120
        '-1210'   => DB_ERROR_INVALID_DATE,
122
        '-1210'   => DB_ERROR_INVALID_DATE,
Line 163... Line 165...
163
 
165
 
164
    // }}}
166
    // }}}
Line 165... Line 167...
165
    // {{{ constructor
167
    // {{{ constructor
166
 
168
 
167
    /**
169
    /**
168
     * This constructor calls <kbd>$this->DB_common()</kbd>
170
     * This constructor calls <kbd>parent::__construct()</kbd>
169
     *
171
     *
170
     * @return void
172
     * @return void
171
     */
173
     */
172
    function DB_ifx()
174
    function __construct()
173
    {
175
    {
Line 174... Line 176...
174
        $this->DB_common();
176
        parent::__construct();
175
    }
177
    }
Line 241... Line 243...
241
     *                + the DB_OK constant for other successful queries
243
     *                + the DB_OK constant for other successful queries
242
     *                + a DB_Error object on failure
244
     *                + a DB_Error object on failure
243
     */
245
     */
244
    function simpleQuery($query)
246
    function simpleQuery($query)
245
    {
247
    {
246
        $ismanip = DB::isManip($query);
248
        $ismanip = $this->_checkManip($query);
247
        $this->last_query = $query;
249
        $this->last_query = $query;
248
        $this->affected   = null;
250
        $this->affected   = null;
249
        if (preg_match('/(SELECT)/i', $query)) {    //TESTME: Use !DB::isManip()?
251
        if (preg_match('/(SELECT|EXECUTE)/i', $query)) {    //TESTME: Use !DB::isManip()?
250
            // the scroll is needed for fetching absolute row numbers
252
            // the scroll is needed for fetching absolute row numbers
251
            // in a select query result
253
            // in a select query result
252
            $result = @ifx_query($query, $this->connection, IFX_SCROLL);
254
            $result = @ifx_query($query, $this->connection, IFX_SCROLL);
253
        } else {
255
        } else {
254
            if (!$this->autocommit && $ismanip) {
256
            if (!$this->autocommit && $ismanip) {
Line 266... Line 268...
266
            return $this->ifxRaiseError();
268
            return $this->ifxRaiseError();
267
        }
269
        }
268
        $this->affected = @ifx_affected_rows($result);
270
        $this->affected = @ifx_affected_rows($result);
269
        // Determine which queries should return data, and which
271
        // Determine which queries should return data, and which
270
        // should return an error code only.
272
        // should return an error code only.
271
        if (preg_match('/(SELECT)/i', $query)) {
273
        if (preg_match('/(SELECT|EXECUTE)/i', $query)) {
272
            return $result;
274
            return $result;
273
        }
275
        }
274
        // XXX Testme: free results inside a transaction
276
        // XXX Testme: free results inside a transaction
275
        // may cause to stop it and commit the work?
277
        // may cause to stop it and commit the work?
Line 307... Line 309...
307
     *
309
     *
308
     * @return int  the number of rows.  A DB_Error object on failure.
310
     * @return int  the number of rows.  A DB_Error object on failure.
309
     */
311
     */
310
    function affectedRows()
312
    function affectedRows()
311
    {
313
    {
312
        if (DB::isManip($this->last_query)) {
314
        if ($this->_last_query_manip) {
313
            return $this->affected;
315
            return $this->affected;
314
        } else {
316
        } else {
315
            return 0;
317
            return 0;
316
        }
318
        }
317
    }
319
    }
Line 418... Line 420...
418
     *
420
     *
419
     * @see DB_result::free()
421
     * @see DB_result::free()
420
     */
422
     */
421
    function freeResult($result)
423
    function freeResult($result)
422
    {
424
    {
423
        return @ifx_free_result($result);
425
        return is_resource($result) ? ifx_free_result($result) : false;
424
    }
426
    }
Line 425... Line 427...
425
 
427
 
426
    // }}}
428
    // }}}
Line 532... Line 534...
532
     * @return int a portable DB error code, or DB_ERROR if this DB
534
     * @return int a portable DB error code, or DB_ERROR if this DB
533
     * implementation has no mapping for the given error code.
535
     * implementation has no mapping for the given error code.
534
     */
536
     */
535
    function errorCode($nativecode)
537
    function errorCode($nativecode)
536
    {
538
    {
537
        if (ereg('SQLCODE=(.*)]', $nativecode, $match)) {
539
        if (preg_match('/SQLCODE=(.*)]/', $nativecode, $match)) {
538
            $code = $match[1];
540
            $code = $match[1];
539
            if (isset($this->errorcode_map[$code])) {
541
            if (isset($this->errorcode_map[$code])) {
540
                return $this->errorcode_map[$code];
542
                return $this->errorcode_map[$code];
541
            }
543
            }
542
        }
544
        }