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 fbsql extension
6
 * The PEAR DB driver for PHP's fbsql extension
7
 * for interacting with FrontBase databases
7
 * for interacting with FrontBase 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     Frank M. Kromann <frank@frontbase.com>
19
 * @author     Frank M. Kromann <frank@frontbase.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: fbsql.php,v 1.82 2005/03/04 23:12:36 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 37... Line 37...
37
 *
37
 *
38
 * @category   Database
38
 * @category   Database
39
 * @package    DB
39
 * @package    DB
40
 * @author     Frank M. Kromann <frank@frontbase.com>
40
 * @author     Frank M. Kromann <frank@frontbase.com>
41
 * @author     Daniel Convissor <danielc@php.net>
41
 * @author     Daniel Convissor <danielc@php.net>
42
 * @copyright  1997-2005 The PHP Group
42
 * @copyright  1997-2007 The PHP Group
43
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
43
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
44
 * @version    Release: 1.7.6
44
 * @version    Release: 1.9.2
45
 * @link       http://pear.php.net/package/DB
45
 * @link       http://pear.php.net/package/DB
46
 * @since      Class functional since Release 1.7.0
46
 * @since      Class functional since Release 1.7.0
47
 */
47
 */
48
class DB_fbsql extends DB_common
48
class DB_fbsql extends DB_common
49
{
49
{
Line 122... Line 122...
122
 
122
 
123
    // }}}
123
    // }}}
Line 124... Line 124...
124
    // {{{ constructor
124
    // {{{ constructor
125
 
125
 
126
    /**
126
    /**
127
     * This constructor calls <kbd>$this->DB_common()</kbd>
127
     * This constructor calls <kbd>parent::__construct()</kbd>
128
     *
128
     *
129
     * @return void
129
     * @return void
130
     */
130
     */
131
    function DB_fbsql()
131
    function __construct()
132
    {
132
    {
Line 133... Line 133...
133
        $this->DB_common();
133
        parent::__construct();
134
    }
134
    }
Line 169... Line 169...
169
        $php_errormsg = '';
169
        $php_errormsg = '';
170
        if ($ini) {
170
        if ($ini) {
171
            $this->connection = @call_user_func_array($connect_function,
171
            $this->connection = @call_user_func_array($connect_function,
172
                                                      $params);
172
                                                      $params);
173
        } else {
173
        } else {
174
            ini_set('track_errors', 1);
174
            @ini_set('track_errors', 1);
175
            $this->connection = @call_user_func_array($connect_function,
175
            $this->connection = @call_user_func_array($connect_function,
176
                                                      $params);
176
                                                      $params);
177
            ini_set('track_errors', $ini);
177
            @ini_set('track_errors', $ini);
178
        }
178
        }
Line 179... Line 179...
179
 
179
 
180
        if (!$this->connection) {
180
        if (!$this->connection) {
181
            return $this->raiseError(DB_ERROR_CONNECT_FAILED,
181
            return $this->raiseError(DB_ERROR_CONNECT_FAILED,
Line 227... Line 227...
227
        if (!$result) {
227
        if (!$result) {
228
            return $this->fbsqlRaiseError();
228
            return $this->fbsqlRaiseError();
229
        }
229
        }
230
        // Determine which queries that should return data, and which
230
        // Determine which queries that should return data, and which
231
        // should return an error code only.
231
        // should return an error code only.
232
        if (DB::isManip($query)) {
232
        if ($this->_checkManip($query)) {
233
            return DB_OK;
233
            return DB_OK;
234
        }
234
        }
235
        return $result;
235
        return $result;
236
    }
236
    }
Line 318... Line 318...
318
     *
318
     *
319
     * @see DB_result::free()
319
     * @see DB_result::free()
320
     */
320
     */
321
    function freeResult($result)
321
    function freeResult($result)
322
    {
322
    {
323
        return @fbsql_free_result($result);
323
        return is_resource($result) ? fbsql_free_result($result) : false;
324
    }
324
    }
Line 325... Line 325...
325
 
325
 
326
    // }}}
326
    // }}}
Line 351... Line 351...
351
     *
351
     *
352
     * @return int  DB_OK on success.  A DB_Error object on failure.
352
     * @return int  DB_OK on success.  A DB_Error object on failure.
353
     */
353
     */
354
    function commit()
354
    function commit()
355
    {
355
    {
356
        @fbsql_commit();
356
        @fbsql_commit($this->connection);
357
    }
357
    }
Line 358... Line 358...
358
 
358
 
359
    // }}}
359
    // }}}
Line 364... Line 364...
364
     *
364
     *
365
     * @return int  DB_OK on success.  A DB_Error object on failure.
365
     * @return int  DB_OK on success.  A DB_Error object on failure.
366
     */
366
     */
367
    function rollback()
367
    function rollback()
368
    {
368
    {
369
        @fbsql_rollback();
369
        @fbsql_rollback($this->connection);
370
    }
370
    }
Line 371... Line 371...
371
 
371
 
372
    // }}}
372
    // }}}
Line 429... Line 429...
429
     *
429
     *
430
     * @return int  the number of rows.  A DB_Error object on failure.
430
     * @return int  the number of rows.  A DB_Error object on failure.
431
     */
431
     */
432
    function affectedRows()
432
    function affectedRows()
433
    {
433
    {
434
        if (DB::isManip($this->last_query)) {
434
        if ($this->_last_query_manip) {
435
            $result = @fbsql_affected_rows($this->connection);
435
            $result = @fbsql_affected_rows($this->connection);
436
        } else {
436
        } else {
437
            $result = 0;
437
            $result = 0;
438
        }
438
        }
439
        return $result;
439
        return $result;
Line 541... Line 541...
541
     *
541
     *
542
     * @access protected
542
     * @access protected
543
     */
543
     */
544
    function modifyLimitQuery($query, $from, $count, $params = array())
544
    function modifyLimitQuery($query, $from, $count, $params = array())
545
    {
545
    {
546
        if (DB::isManip($query)) {
546
        if (DB::isManip($query) || $this->_next_query_manip) {
547
            return preg_replace('/^([\s(])*SELECT/i',
547
            return preg_replace('/^([\s(])*SELECT/i',
548
                                "\\1SELECT TOP($count)", $query);
548
                                "\\1SELECT TOP($count)", $query);
549
        } else {
549
        } else {
550
            return preg_replace('/([\s(])*SELECT/i',
550
            return preg_replace('/([\s(])*SELECT/i',
551
                                "\\1SELECT TOP($from, $count)", $query);
551
                                "\\1SELECT TOP($from, $count)", $query);
552
        }
552
        }
553
    }
553
    }
Line 554... Line 554...
554
 
554
 
555
    // }}}
555
    // }}}
Line 556... Line 556...
556
    // {{{ quoteSmart()
556
    // {{{ quoteBoolean()
557
 
557
 
558
    /**
558
    /**
559
     * Formats input so it can be safely used in a query
-
 
560
     *
-
 
561
     * @param mixed $in  the data to be formatted
-
 
562
     *
-
 
563
     * @return mixed  the formatted data.  The format depends on the input's
-
 
564
     *                 PHP type:
-
 
565
     *                 + null = the string <samp>NULL</samp>
-
 
566
     *                 + boolean = string <samp>TRUE</samp> or <samp>FALSE</samp>
-
 
567
     *                 + integer or double = the unquoted number
-
 
568
     *                 + other (including strings and numeric strings) =
-
 
569
     *                   the data escaped according to FrontBase's settings
559
     * Formats a boolean value for use within a query in a locale-independent
-
 
560
     * manner.
-
 
561
     *
570
     *                   then encapsulated between single quotes
562
     * @param boolean the boolean value to be quoted.
571
     *
563
     * @return string the quoted string.
572
     * @see DB_common::quoteSmart()
564
     * @see DB_common::quoteSmart()
573
     * @since Method available since Release 1.6.0
565
     * @since Method available since release 1.7.8.
574
     */
-
 
575
    function quoteSmart($in)
-
 
576
    {
-
 
577
        if (is_int($in) || is_double($in)) {
-
 
578
            return $in;
566
     */
579
        } elseif (is_bool($in)) {
-
 
580
            return $in ? 'TRUE' : 'FALSE';
-
 
581
        } elseif (is_null($in)) {
-
 
582
            return 'NULL';
-
 
583
        } else {
-
 
584
            return "'" . $this->escapeSimple($in) . "'";
567
    function quoteBoolean($boolean) {
-
 
568
        return $boolean ? 'TRUE' : 'FALSE';
-
 
569
    }
-
 
570
     
Line -... Line 571...
-
 
571
    // }}}
-
 
572
    // {{{ quoteFloat()
-
 
573
 
-
 
574
    /**
-
 
575
     * Formats a float value for use within a query in a locale-independent
-
 
576
     * manner.
-
 
577
     *
-
 
578
     * @param float the float value to be quoted.
-
 
579
     * @return string the quoted string.
-
 
580
     * @see DB_common::quoteSmart()
-
 
581
     * @since Method available since release 1.7.8.
-
 
582
     */
-
 
583
    function quoteFloat($float) {
585
        }
584
        return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
586
    }
585
    }
Line 587... Line 586...
587
 
586
     
588
    // }}}
587
    // }}}