| 1 |
cvsjoko |
1.1 |
<?php |
| 2 |
|
|
// |
| 3 |
|
|
// +----------------------------------------------------------------------+ |
| 4 |
|
|
// | PHP Version 4 | |
| 5 |
|
|
// +----------------------------------------------------------------------+ |
| 6 |
|
|
// | Copyright (c) 1997-2002 The PHP Group | |
| 7 |
|
|
// +----------------------------------------------------------------------+ |
| 8 |
|
|
// | This source file is subject to version 2.02 of the PHP license, | |
| 9 |
|
|
// | that is bundled with this package in the file LICENSE, and is | |
| 10 |
|
|
// | available at through the world-wide-web at | |
| 11 |
|
|
// | http://www.php.net/license/2_02.txt. | |
| 12 |
|
|
// | If you did not receive a copy of the PHP license and are unable to | |
| 13 |
|
|
// | obtain it through the world-wide-web, please send a note to | |
| 14 |
|
|
// | license@php.net so we can mail you a copy immediately. | |
| 15 |
|
|
// +----------------------------------------------------------------------+ |
| 16 |
|
|
// | Author: Tomas V.V.Cox <cox@idecnet.com> | |
| 17 |
|
|
// +----------------------------------------------------------------------+ |
| 18 |
|
|
// |
| 19 |
|
|
// $Id: dbase.php,v 1.2 2002/02/28 08:27:08 sebastian Exp $ |
| 20 |
|
|
// |
| 21 |
|
|
// Database independent query interface definition for PHP's dbase |
| 22 |
|
|
// extension. |
| 23 |
|
|
// |
| 24 |
|
|
// XXX legend: |
| 25 |
|
|
// You have to compile your PHP with the --enable-dbase option |
| 26 |
|
|
// |
| 27 |
|
|
|
| 28 |
|
|
require_once "DB/common.php"; |
| 29 |
|
|
|
| 30 |
|
|
class DB_dbase extends DB_common |
| 31 |
|
|
{ |
| 32 |
|
|
// {{{ properties |
| 33 |
|
|
|
| 34 |
|
|
var $connection; |
| 35 |
|
|
var $phptype, $dbsyntax; |
| 36 |
|
|
var $prepare_tokens = array(); |
| 37 |
|
|
var $prepare_types = array(); |
| 38 |
|
|
var $transaction_opcount = 0; |
| 39 |
|
|
var $res_row = array(); |
| 40 |
|
|
var $result = 0; |
| 41 |
|
|
|
| 42 |
|
|
// }}} |
| 43 |
|
|
// {{{ constructor |
| 44 |
|
|
|
| 45 |
|
|
/** |
| 46 |
|
|
* DB_mysql constructor. |
| 47 |
|
|
* |
| 48 |
|
|
* @access public |
| 49 |
|
|
*/ |
| 50 |
|
|
|
| 51 |
|
|
function DB_dbase() |
| 52 |
|
|
{ |
| 53 |
|
|
$this->DB_common(); |
| 54 |
|
|
$this->phptype = 'dbase'; |
| 55 |
|
|
$this->dbsyntax = 'dbase'; |
| 56 |
|
|
$this->features = array( |
| 57 |
|
|
'prepare' => false, |
| 58 |
|
|
'pconnect' => false, |
| 59 |
|
|
'transactions' => false, |
| 60 |
|
|
'limit' => false |
| 61 |
|
|
); |
| 62 |
|
|
$this->errorcode_map = array(); |
| 63 |
|
|
} |
| 64 |
|
|
|
| 65 |
|
|
function connect($dsninfo, $persistent = false) |
| 66 |
|
|
{ |
| 67 |
|
|
if (!DB::assertExtension('dbase')) { |
| 68 |
|
|
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND); |
| 69 |
|
|
} |
| 70 |
|
|
$this->dsn = $dsninfo; |
| 71 |
|
|
ob_start(); |
| 72 |
|
|
$conn = dbase_open($dsninfo['database'], 0); |
| 73 |
|
|
$error = ob_get_contents(); |
| 74 |
|
|
ob_end_clean(); |
| 75 |
|
|
if (!$conn) { |
| 76 |
|
|
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, |
| 77 |
|
|
null, null, strip_tags($error)); |
| 78 |
|
|
} |
| 79 |
|
|
$this->connection = $conn; |
| 80 |
|
|
return DB_OK; |
| 81 |
|
|
} |
| 82 |
|
|
|
| 83 |
|
|
function disconnect() |
| 84 |
|
|
{ |
| 85 |
|
|
$ret = dbase_close($this->connection); |
| 86 |
|
|
$this->connection = null; |
| 87 |
|
|
return $ret; |
| 88 |
|
|
} |
| 89 |
|
|
|
| 90 |
|
|
function &query($query = null) |
| 91 |
|
|
{ |
| 92 |
|
|
// emulate result resources |
| 93 |
|
|
$this->res_row[$this->result] = 0; |
| 94 |
|
|
return new DB_result($this, $this->result++); |
| 95 |
|
|
} |
| 96 |
|
|
|
| 97 |
|
|
function fetchInto($res, &$row, $fetchmode, $rownum = null) |
| 98 |
|
|
{ |
| 99 |
|
|
if ($rownum === null) { |
| 100 |
|
|
$rownum = $this->res_row[$res]++; |
| 101 |
|
|
} |
| 102 |
|
|
if ($fetchmode & DB_FETCHMODE_ASSOC) { |
| 103 |
|
|
$row = @dbase_get_record_with_names($this->connection, $rownum); |
| 104 |
|
|
} else { |
| 105 |
|
|
$row = @dbase_get_record($this->connection, $rownum); |
| 106 |
|
|
} |
| 107 |
|
|
if (!$row) { |
| 108 |
|
|
return null; |
| 109 |
|
|
} |
| 110 |
|
|
return DB_OK; |
| 111 |
|
|
} |
| 112 |
|
|
|
| 113 |
|
|
function numCols($foo) |
| 114 |
|
|
{ |
| 115 |
|
|
return dbase_numfields($this->connection); |
| 116 |
|
|
} |
| 117 |
|
|
|
| 118 |
|
|
function numRows($foo) |
| 119 |
|
|
{ |
| 120 |
|
|
return dbase_numrecords($this->connection); |
| 121 |
|
|
} |
| 122 |
|
|
} |
| 123 |
|
|
?> |