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 dbase extension
6
 * The PEAR DB driver for PHP's dbase extension
7
 * for interacting with dBase databases
7
 * for interacting with dBase 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: dbase.php,v 1.39 2005/02/19 23:25:25 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     Tomas V.V. Cox <cox@idecnet.com>
40
 * @author     Tomas V.V. Cox <cox@idecnet.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
 */
46
 */
47
class DB_dbase extends DB_common
47
class DB_dbase extends DB_common
48
{
48
{
49
    // {{{ properties
49
    // {{{ properties
Line 138... Line 138...
138
 
138
 
139
    // }}}
139
    // }}}
Line 140... Line 140...
140
    // {{{ constructor
140
    // {{{ constructor
141
 
141
 
142
    /**
142
    /**
143
     * This constructor calls <kbd>$this->DB_common()</kbd>
143
     * This constructor calls <kbd>parent::__construct()</kbd>
144
     *
144
     *
145
     * @return void
145
     * @return void
146
     */
146
     */
147
    function DB_dbase()
147
    function __construct()
148
    {
148
    {
Line 149... Line 149...
149
        $this->DB_common();
149
        parent::__construct();
150
    }
150
    }
Line 186... Line 186...
186
     * $options = array(
186
     * $options = array(
187
     *     'debug'       => 2,
187
     *     'debug'       => 2,
188
     *     'portability' => DB_PORTABILITY_ALL,
188
     *     'portability' => DB_PORTABILITY_ALL,
189
     * );
189
     * );
190
     *
190
     *
191
     * $db =& DB::connect($dsn, $options);
191
     * $db = DB::connect($dsn, $options);
192
     * if (PEAR::isError($db)) {
192
     * if (PEAR::isError($db)) {
193
     *     die($db->getMessage());
193
     *     die($db->getMessage());
194
     * }
194
     * }
195
     * </code>
195
     * </code>
196
     *
196
     *
Line 212... Line 212...
212
 
212
 
213
        /*
213
        /*
214
         * Turn track_errors on for entire script since $php_errormsg
214
         * Turn track_errors on for entire script since $php_errormsg
215
         * is the only way to find errors from the dbase extension.
215
         * is the only way to find errors from the dbase extension.
216
         */
216
         */
217
        ini_set('track_errors', 1);
217
        @ini_set('track_errors', 1);
Line 218... Line 218...
218
        $php_errormsg = '';
218
        $php_errormsg = '';
219
 
219
 
220
        if (!file_exists($dsn['database'])) {
220
        if (!file_exists($dsn['database'])) {
Line 271... Line 271...
271
 
271
 
272
    function &query($query = null)
272
    function &query($query = null)
273
    {
273
    {
274
        // emulate result resources
274
        // emulate result resources
275
        $this->res_row[(int)$this->result] = 0;
275
        $this->res_row[(int)$this->result] = 0;
276
        $tmp =& new DB_result($this, $this->result++);
276
        $tmp = new DB_result($this, $this->result++);
277
        return $tmp;
277
        return $tmp;
Line 278... Line 278...
278
    }
278
    }
279
 
279
 
Line 324... Line 324...
324
        }
324
        }
325
        return DB_OK;
325
        return DB_OK;
326
    }
326
    }
Line 327... Line 327...
327
 
327
 
-
 
328
    // }}}
-
 
329
    // {{{ freeResult()
-
 
330
 
-
 
331
    /**
-
 
332
     * Deletes the result set and frees the memory occupied by the result set.
-
 
333
     *
-
 
334
     * This method is a no-op for dbase, as there aren't result resources in
-
 
335
     * the same sense as most other database backends.
-
 
336
     *
-
 
337
     * @param resource $result  PHP's query result resource
-
 
338
     *
-
 
339
     * @return bool  TRUE on success, FALSE if $result is invalid
-
 
340
     *
-
 
341
     * @see DB_result::free()
-
 
342
     */
-
 
343
    function freeResult($result)
-
 
344
    {
-
 
345
        return true;
-
 
346
    }
-
 
347
 
328
    // }}}
348
    // }}}
Line 329... Line 349...
329
    // {{{ numCols()
349
    // {{{ numCols()
330
 
350
 
331
    /**
351
    /**
Line 366... Line 386...
366
    {
386
    {
367
        return @dbase_numrecords($this->connection);
387
        return @dbase_numrecords($this->connection);
368
    }
388
    }
Line 369... Line 389...
369
 
389
 
370
    // }}}
390
    // }}}
Line 371... Line 391...
371
    // {{{ quoteSmart()
391
    // {{{ quoteBoolean()
372
 
392
 
373
    /**
393
    /**
374
     * Formats input so it can be safely used in a query
-
 
375
     *
-
 
376
     * @param mixed $in  the data to be formatted
-
 
377
     *
-
 
378
     * @return mixed  the formatted data.  The format depends on the input's
-
 
379
     *                 PHP type:
-
 
380
     *                 + null = the string <samp>NULL</samp>
-
 
381
     *                 + boolean = <samp>T</samp> if true or
-
 
382
     *                   <samp>F</samp> if false.  Use the <kbd>Logical</kbd>
-
 
383
     *                   data type.
-
 
384
     *                 + integer or double = the unquoted number
-
 
385
     *                 + other (including strings and numeric strings) =
-
 
386
     *                   the data with single quotes escaped by preceeding
-
 
387
     *                   single quotes then the whole string is encapsulated
394
     * Formats a boolean value for use within a query in a locale-independent
-
 
395
     * manner.
-
 
396
     *
388
     *                   between single quotes
397
     * @param boolean the boolean value to be quoted.
389
     *
398
     * @return string the quoted string.
390
     * @see DB_common::quoteSmart()
399
     * @see DB_common::quoteSmart()
391
     * @since Method available since Release 1.6.0
400
     * @since Method available since release 1.7.8.
392
     */
-
 
393
    function quoteSmart($in)
-
 
394
    {
-
 
395
        if (is_int($in) || is_double($in)) {
-
 
396
            return $in;
401
     */
397
        } elseif (is_bool($in)) {
-
 
398
            return $in ? 'T' : 'F';
-
 
399
        } elseif (is_null($in)) {
-
 
400
            return 'NULL';
-
 
401
        } else {
-
 
402
            return "'" . $this->escapeSimple($in) . "'";
402
    function quoteBoolean($boolean) {
403
        }
403
        return $boolean ? 'T' : 'F';
404
    }
404
    }
405
 
405
     
Line 406... Line 406...
406
    // }}}
406
    // }}}
407
    // {{{ tableInfo()
407
    // {{{ tableInfo()