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 8... Line 8...
8
 *
8
 *
9
 * PHP's mSQL extension did weird things with NULL values prior to PHP
9
 * PHP's mSQL extension did weird things with NULL values prior to PHP
10
 * 4.3.11 and 5.0.4.  Make sure your version of PHP meets or exceeds
10
 * 4.3.11 and 5.0.4.  Make sure your version of PHP meets or exceeds
11
 * those versions.
11
 * those versions.
12
 *
12
 *
13
 * PHP versions 4 and 5
13
 * PHP version 5
14
 *
14
 *
15
 * LICENSE: This source file is subject to version 3.0 of the PHP license
15
 * LICENSE: This source file is subject to version 3.0 of the PHP license
16
 * that is available through the world-wide-web at the following URI:
16
 * that is available through the world-wide-web at the following URI:
17
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
17
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
18
 * the PHP License and are unable to obtain it through the web, please
18
 * the PHP License and are unable to obtain it through the web, please
19
 * send a note to license@php.net so we can mail you a copy immediately.
19
 * send a note to license@php.net so we can mail you a copy immediately.
20
 *
20
 *
21
 * @category   Database
21
 * @category   Database
22
 * @package    DB
22
 * @package    DB
23
 * @author     Daniel Convissor <danielc@php.net>
23
 * @author     Daniel Convissor <danielc@php.net>
24
 * @copyright  1997-2005 The PHP Group
24
 * @copyright  1997-2007 The PHP Group
25
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
25
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
26
 * @version    CVS: $Id: msql.php,v 1.57 2005/02/22 07:26:46 danielc Exp $
26
 * @version    CVS: $Id$
27
 * @link       http://pear.php.net/package/DB
27
 * @link       http://pear.php.net/package/DB
28
 */
28
 */
Line 29... Line 29...
29
 
29
 
30
/**
30
/**
Line 43... Line 43...
43
 * those versions.
43
 * those versions.
44
 *
44
 *
45
 * @category   Database
45
 * @category   Database
46
 * @package    DB
46
 * @package    DB
47
 * @author     Daniel Convissor <danielc@php.net>
47
 * @author     Daniel Convissor <danielc@php.net>
48
 * @copyright  1997-2005 The PHP Group
48
 * @copyright  1997-2007 The PHP Group
49
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
49
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
50
 * @version    Release: 1.7.6
50
 * @version    Release: 1.9.2
51
 * @link       http://pear.php.net/package/DB
51
 * @link       http://pear.php.net/package/DB
52
 * @since      Class not functional until Release 1.7.0
52
 * @since      Class not functional until Release 1.7.0
53
 */
53
 */
54
class DB_msql extends DB_common
54
class DB_msql extends DB_common
55
{
55
{
Line 124... Line 124...
124
 
124
 
125
    // }}}
125
    // }}}
Line 126... Line 126...
126
    // {{{ constructor
126
    // {{{ constructor
127
 
127
 
128
    /**
128
    /**
129
     * This constructor calls <kbd>$this->DB_common()</kbd>
129
     * This constructor calls <kbd>parent::__construct()</kbd>
130
     *
130
     *
131
     * @return void
131
     * @return void
132
     */
132
     */
133
    function DB_msql()
133
    function __construct()
134
    {
134
    {
Line 135... Line 135...
135
        $this->DB_common();
135
        parent::__construct();
136
    }
136
    }
Line 151... Line 151...
151
     * $dsn = 'msql:///dbname';             // use a socket
151
     * $dsn = 'msql:///dbname';             // use a socket
152
     * $options = array(
152
     * $options = array(
153
     *     'portability' => DB_PORTABILITY_ALL,
153
     *     'portability' => DB_PORTABILITY_ALL,
154
     * );
154
     * );
155
     * 
155
     * 
156
     * $db =& DB::connect($dsn, $options);
156
     * $db = DB::connect($dsn, $options);
157
     * if (PEAR::isError($db)) {
157
     * if (PEAR::isError($db)) {
158
     *     die($db->getMessage());
158
     *     die($db->getMessage());
159
     * }
159
     * }
160
     * </code>
160
     * </code>
161
     *
161
     *
Line 188... Line 188...
188
        $php_errormsg = '';
188
        $php_errormsg = '';
189
        if ($ini) {
189
        if ($ini) {
190
            $this->connection = @call_user_func_array($connect_function,
190
            $this->connection = @call_user_func_array($connect_function,
191
                                                      $params);
191
                                                      $params);
192
        } else {
192
        } else {
193
            ini_set('track_errors', 1);
193
            @ini_set('track_errors', 1);
194
            $this->connection = @call_user_func_array($connect_function,
194
            $this->connection = @call_user_func_array($connect_function,
195
                                                      $params);
195
                                                      $params);
196
            ini_set('track_errors', $ini);
196
            @ini_set('track_errors', $ini);
197
        }
197
        }
Line 198... Line 198...
198
 
198
 
199
        if (!$this->connection) {
199
        if (!$this->connection) {
200
            if (($err = @msql_error()) != '') {
200
            if (($err = @msql_error()) != '') {
Line 249... Line 249...
249
        if (!$result) {
249
        if (!$result) {
250
            return $this->msqlRaiseError();
250
            return $this->msqlRaiseError();
251
        }
251
        }
252
        // Determine which queries that should return data, and which
252
        // Determine which queries that should return data, and which
253
        // should return an error code only.
253
        // should return an error code only.
254
        if (DB::isManip($query)) {
254
        if ($this->_checkManip($query)) {
255
            $this->_result = $result;
255
            $this->_result = $result;
256
            return DB_OK;
256
            return DB_OK;
257
        } else {
257
        } else {
258
            $this->_result = false;
258
            $this->_result = false;
259
            return $result;
259
            return $result;
Line 348... Line 348...
348
     *
348
     *
349
     * @see DB_result::free()
349
     * @see DB_result::free()
350
     */
350
     */
351
    function freeResult($result)
351
    function freeResult($result)
352
    {
352
    {
353
        return @msql_free_result($result);
353
        return is_resource($result) ? msql_free_result($result) : false;
354
    }
354
    }
Line 355... Line 355...
355
 
355
 
356
    // }}}
356
    // }}}
Line 441... Line 441...
441
    {
441
    {
442
        $seqname = $this->getSequenceName($seq_name);
442
        $seqname = $this->getSequenceName($seq_name);
443
        $repeat = false;
443
        $repeat = false;
444
        do {
444
        do {
445
            $this->pushErrorHandling(PEAR_ERROR_RETURN);
445
            $this->pushErrorHandling(PEAR_ERROR_RETURN);
446
            $result =& $this->query("SELECT _seq FROM ${seqname}");
446
            $result = $this->query("SELECT _seq FROM ${seqname}");
447
            $this->popErrorHandling();
447
            $this->popErrorHandling();
448
            if ($ondemand && DB::isError($result) &&
448
            if ($ondemand && DB::isError($result) &&
449
                $result->getCode() == DB_ERROR_NOSUCHTABLE) {
449
                $result->getCode() == DB_ERROR_NOSUCHTABLE) {
450
                $repeat = true;
450
                $repeat = true;
451
                $this->pushErrorHandling(PEAR_ERROR_RETURN);
451
                $this->pushErrorHandling(PEAR_ERROR_RETURN);
Line 529... Line 529...
529
    {
529
    {
530
        return $this->raiseError(DB_ERROR_UNSUPPORTED);
530
        return $this->raiseError(DB_ERROR_UNSUPPORTED);
531
    }
531
    }
Line 532... Line 532...
532
 
532
 
-
 
533
    // }}}
-
 
534
    // {{{ quoteFloat()
-
 
535
 
-
 
536
    /**
-
 
537
     * Formats a float value for use within a query in a locale-independent
-
 
538
     * manner.
-
 
539
     *
-
 
540
     * @param float the float value to be quoted.
-
 
541
     * @return string the quoted string.
-
 
542
     * @see DB_common::quoteSmart()
-
 
543
     * @since Method available since release 1.7.8.
-
 
544
     */
-
 
545
    function quoteFloat($float) {
-
 
546
        return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
-
 
547
    }
-
 
548
     
533
    // }}}
549
    // }}}
Line 534... Line 550...
534
    // {{{ escapeSimple()
550
    // {{{ escapeSimple()
535
 
551
 
536
    /**
552
    /**
Line 596... Line 612...
596
     * @return integer  the error number from a DB_ERROR* constant
612
     * @return integer  the error number from a DB_ERROR* constant
597
     */
613
     */
598
    function errorCode($errormsg)
614
    function errorCode($errormsg)
599
    {
615
    {
600
        static $error_regexps;
616
        static $error_regexps;
-
 
617
        
-
 
618
        // PHP 5.2+ prepends the function name to $php_errormsg, so we need
-
 
619
        // this hack to work around it, per bug #9599.
-
 
620
        $errormsg = preg_replace('/^msql[a-z_]+\(\): /', '', $errormsg);
-
 
621
 
601
        if (!isset($error_regexps)) {
622
        if (!isset($error_regexps)) {
602
            $error_regexps = array(
623
            $error_regexps = array(
603
                '/^Access to database denied/i'
624
                '/^Access to database denied/i'
604
                    => DB_ERROR_ACCESS_VIOLATION,
625
                    => DB_ERROR_ACCESS_VIOLATION,
605
                '/^Bad index name/i'
626
                '/^Bad index name/i'