extlib/DB/DataObject - Fix PHP 7.3 Warning switch continue -> break
Also reformatted under PSR norms
This commit is contained in:
parent
8305641b20
commit
38f2ecefac
File diff suppressed because it is too large
Load Diff
@ -53,7 +53,8 @@
|
||||
*
|
||||
|
||||
*/
|
||||
class DB_DataObject_Cast {
|
||||
class DB_DataObject_Cast
|
||||
{
|
||||
|
||||
/**
|
||||
* Type of data Stored in the object..
|
||||
@ -61,7 +62,7 @@ class DB_DataObject_Cast {
|
||||
* @var string (date|blob|.....?)
|
||||
* @access public
|
||||
*/
|
||||
var $type;
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Data For date representation
|
||||
@ -69,9 +70,9 @@ class DB_DataObject_Cast {
|
||||
* @var int day/month/year
|
||||
* @access public
|
||||
*/
|
||||
var $day;
|
||||
var $month;
|
||||
var $year;
|
||||
public $day;
|
||||
public $month;
|
||||
public $year;
|
||||
|
||||
|
||||
/**
|
||||
@ -81,7 +82,7 @@ class DB_DataObject_Cast {
|
||||
* @access public
|
||||
*/
|
||||
|
||||
var $value;
|
||||
public $value;
|
||||
|
||||
|
||||
|
||||
@ -97,7 +98,8 @@ class DB_DataObject_Cast {
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function blob($value) {
|
||||
public function blob($value)
|
||||
{
|
||||
$r = new DB_DataObject_Cast;
|
||||
$r->type = 'blob';
|
||||
$r->value = $value;
|
||||
@ -117,7 +119,8 @@ class DB_DataObject_Cast {
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function string($value) {
|
||||
public function string($value)
|
||||
{
|
||||
$r = new DB_DataObject_Cast;
|
||||
$r->type = 'string';
|
||||
$r->value = $value;
|
||||
@ -135,7 +138,7 @@ class DB_DataObject_Cast {
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function sql($value)
|
||||
public function sql($value)
|
||||
{
|
||||
$r = new DB_DataObject_Cast;
|
||||
$r->type = 'sql';
|
||||
@ -164,19 +167,19 @@ class DB_DataObject_Cast {
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function date()
|
||||
public function date()
|
||||
{
|
||||
$args = func_get_args();
|
||||
switch(count($args)) {
|
||||
switch (count($args)) {
|
||||
case 0: // no args = today!
|
||||
$bits = explode('-',date('Y-m-d'));
|
||||
$bits = explode('-', date('Y-m-d'));
|
||||
break;
|
||||
case 1: // one arg = a string
|
||||
|
||||
if (strpos($args[0],'/') !== false) {
|
||||
$bits = array_reverse(explode('/',$args[0]));
|
||||
if (strpos($args[0], '/') !== false) {
|
||||
$bits = array_reverse(explode('/', $args[0]));
|
||||
} else {
|
||||
$bits = explode('-',$args[0]);
|
||||
$bits = explode('-', $args[0]);
|
||||
}
|
||||
break;
|
||||
default: // 2 or more..
|
||||
@ -196,15 +199,15 @@ class DB_DataObject_Cast {
|
||||
// fix me if anyone has more time...
|
||||
if (($bits[0] < 1975) || ($bits[0] > 2030)) {
|
||||
$oldyear = $bits[0];
|
||||
$bits = explode('-',date('Y-m-d',mktime(1,1,1,$bits[1],$bits[2],2000)));
|
||||
$bits = explode('-', date('Y-m-d', mktime(1, 1, 1, $bits[1], $bits[2], 2000)));
|
||||
$bits[0] = ($bits[0] - 2000) + $oldyear;
|
||||
} else {
|
||||
// now mktime
|
||||
$bits = explode('-',date('Y-m-d',mktime(1,1,1,$bits[1],$bits[2],$bits[0])));
|
||||
$bits = explode('-', date('Y-m-d', mktime(1, 1, 1, $bits[1], $bits[2], $bits[0])));
|
||||
}
|
||||
$r = new DB_DataObject_Cast;
|
||||
$r->type = 'date';
|
||||
list($r->year,$r->month,$r->day) = $bits;
|
||||
list($r->year, $r->month, $r->day) = $bits;
|
||||
return $r;
|
||||
}
|
||||
|
||||
@ -216,9 +219,9 @@ class DB_DataObject_Cast {
|
||||
* @var int hour/minute/second
|
||||
* @access public
|
||||
*/
|
||||
var $hour;
|
||||
var $minute;
|
||||
var $second;
|
||||
public $hour;
|
||||
public $minute;
|
||||
public $second;
|
||||
|
||||
|
||||
/**
|
||||
@ -239,13 +242,14 @@ class DB_DataObject_Cast {
|
||||
* @author therion 5 at hotmail
|
||||
*/
|
||||
|
||||
function dateTime()
|
||||
public function dateTime()
|
||||
{
|
||||
$args = func_get_args();
|
||||
switch(count($args)) {
|
||||
switch (count($args)) {
|
||||
case 0: // no args = now!
|
||||
$datetime = date('Y-m-d G:i:s', mktime());
|
||||
|
||||
// no break
|
||||
case 1:
|
||||
// continue on from 0 args.
|
||||
if (!isset($datetime)) {
|
||||
@ -280,7 +284,6 @@ class DB_DataObject_Cast {
|
||||
$r->minute = $bits[4];
|
||||
$r->second = $bits[5];
|
||||
return $r;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -302,13 +305,14 @@ class DB_DataObject_Cast {
|
||||
* @access public
|
||||
* @author therion 5 at hotmail
|
||||
*/
|
||||
function time()
|
||||
public function time()
|
||||
{
|
||||
$args = func_get_args();
|
||||
switch (count($args)) {
|
||||
case 0: // no args = now!
|
||||
$time = date('G:i:s', mktime());
|
||||
|
||||
// no break
|
||||
case 1:
|
||||
// continue on from 0 args.
|
||||
if (!isset($time)) {
|
||||
@ -333,7 +337,6 @@ class DB_DataObject_Cast {
|
||||
$r->minute = $bits[1];
|
||||
$r->second = $bits[2];
|
||||
return $r;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -350,12 +353,12 @@ class DB_DataObject_Cast {
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function toString($to=false,$db)
|
||||
public function toString($to=false, $db)
|
||||
{
|
||||
// if $this->type is not set, we are in serious trouble!!!!
|
||||
// values for to:
|
||||
$method = 'toStringFrom'.$this->type;
|
||||
return $this->$method($to,$db);
|
||||
return $this->$method($to, $db);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -369,7 +372,7 @@ class DB_DataObject_Cast {
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
function toStringFromBlob($to,$db)
|
||||
public function toStringFromBlob($to, $db)
|
||||
{
|
||||
// first weed out invalid casts..
|
||||
// in blobs can only be cast to blobs.!
|
||||
@ -385,7 +388,7 @@ class DB_DataObject_Cast {
|
||||
return "'".pg_escape_bytea($this->value)."'::bytea";
|
||||
|
||||
case 'mysql':
|
||||
return "'".mysql_real_escape_string($this->value,$db->connection)."'";
|
||||
return "'".mysql_real_escape_string($this->value, $db->connection)."'";
|
||||
|
||||
case 'mysqli':
|
||||
// this is funny - the parameter order is reversed ;)
|
||||
@ -397,7 +400,7 @@ class DB_DataObject_Cast {
|
||||
|
||||
case 'mssql':
|
||||
|
||||
if(is_numeric($this->value)) {
|
||||
if (is_numeric($this->value)) {
|
||||
return $this->value;
|
||||
}
|
||||
$unpacked = unpack('H*hex', $this->value);
|
||||
@ -408,7 +411,6 @@ class DB_DataObject_Cast {
|
||||
default:
|
||||
return PEAR::raiseError("DB_DataObject_Cast cant handle blobs for Database:{$db->dsn['phptype']} Yet");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -423,7 +425,7 @@ class DB_DataObject_Cast {
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
function toStringFromString($to,$db)
|
||||
public function toStringFromString($to, $db)
|
||||
{
|
||||
// first weed out invalid casts..
|
||||
// in blobs can only be cast to blobs.!
|
||||
@ -441,7 +443,7 @@ class DB_DataObject_Cast {
|
||||
return "'".pg_escape_string($this->value)."'::bytea";
|
||||
|
||||
case 'mysql':
|
||||
return "'".mysql_real_escape_string($this->value,$db->connection)."'";
|
||||
return "'".mysql_real_escape_string($this->value, $db->connection)."'";
|
||||
|
||||
|
||||
case 'mysqli':
|
||||
@ -459,7 +461,6 @@ class DB_DataObject_Cast {
|
||||
default:
|
||||
return PEAR::raiseError("DB_DataObject_Cast cant handle blobs for Database:{$db->dsn['phptype']} Yet");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -475,7 +476,7 @@ class DB_DataObject_Cast {
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
function toStringFromDate($to,$db)
|
||||
public function toStringFromDate($to, $db)
|
||||
{
|
||||
// first weed out invalid casts..
|
||||
// in blobs can only be cast to blobs.!
|
||||
@ -503,7 +504,7 @@ class DB_DataObject_Cast {
|
||||
* @author therion 5 at hotmail
|
||||
*/
|
||||
|
||||
function toStringFromDateTime($to,$db)
|
||||
public function toStringFromDateTime($to, $db)
|
||||
{
|
||||
// first weed out invalid casts..
|
||||
// in blobs can only be cast to blobs.!
|
||||
@ -531,7 +532,7 @@ class DB_DataObject_Cast {
|
||||
* @author therion 5 at hotmail
|
||||
*/
|
||||
|
||||
function toStringFromTime($to,$db)
|
||||
public function toStringFromTime($to, $db)
|
||||
{
|
||||
// first weed out invalid casts..
|
||||
// in blobs can only be cast to blobs.!
|
||||
@ -554,12 +555,8 @@ class DB_DataObject_Cast {
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
function toStringFromSql($to,$db)
|
||||
public function toStringFromSql($to, $db)
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,16 +38,15 @@ class DB_DataObject_Error extends PEAR_Error
|
||||
*
|
||||
* @see PEAR_Error
|
||||
*/
|
||||
function DB_DataObject_Error($message = '', $code = DB_ERROR, $mode = PEAR_ERROR_RETURN,
|
||||
$level = E_USER_NOTICE)
|
||||
{
|
||||
public function DB_DataObject_Error(
|
||||
$message = '',
|
||||
$code = DB_ERROR,
|
||||
$mode = PEAR_ERROR_RETURN,
|
||||
$level = E_USER_NOTICE
|
||||
) {
|
||||
$this->PEAR_Error('DB_DataObject Error: ' . $message, $code, $mode, $level);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// todo : - support code -> message handling, and translated error messages...
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -41,39 +41,39 @@ class DB_DataObject_Links
|
||||
/**
|
||||
* @property {DB_DataObject} do DataObject to apply this to.
|
||||
*/
|
||||
var $do = false;
|
||||
public $do = false;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Array|String} load What to load, 'all' or an array of properties. (default all)
|
||||
*/
|
||||
var $load = 'all';
|
||||
public $load = 'all';
|
||||
/**
|
||||
* @property {String|Boolean} scanf use part of column name as resulting
|
||||
* property name. (default false)
|
||||
*/
|
||||
var $scanf = false;
|
||||
public $scanf = false;
|
||||
/**
|
||||
* @property {String|Boolean} printf use column name as sprintf for resulting property name..
|
||||
* (default %s_link if apply is true, otherwise it is %s)
|
||||
*/
|
||||
var $printf = false;
|
||||
public $printf = false;
|
||||
/**
|
||||
* @property {Boolean} cached cache the result, so future queries will use cache rather
|
||||
* than running the expensive sql query.
|
||||
*/
|
||||
var $cached = false;
|
||||
public $cached = false;
|
||||
/**
|
||||
* @property {Boolean} apply apply the result to this object, (default true)
|
||||
*/
|
||||
var $apply = true;
|
||||
public $apply = true;
|
||||
|
||||
|
||||
//------------------------- RETURN ------------------------------------
|
||||
/**
|
||||
* @property {Array} links key value associative array of links.
|
||||
*/
|
||||
var $links;
|
||||
public $links;
|
||||
|
||||
|
||||
/**
|
||||
@ -83,16 +83,14 @@ class DB_DataObject_Links
|
||||
* @param {Array} cfg Configuration (basically properties of this object)
|
||||
*/
|
||||
|
||||
function DB_DataObject_Links($do,$cfg= array())
|
||||
public function DB_DataObject_Links($do, $cfg= array())
|
||||
{
|
||||
// check if do is set!!!?
|
||||
$this->do = $do;
|
||||
|
||||
foreach($cfg as $k=>$v) {
|
||||
foreach ($cfg as $k=>$v) {
|
||||
$this->$k = $v;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,20 +108,17 @@ class DB_DataObject_Links
|
||||
* @access public
|
||||
* @return mixed object on success false on failure or '0' when not linked
|
||||
*/
|
||||
function getLink($field, $table= false, $link='')
|
||||
public function getLink($field, $table= false, $link='')
|
||||
{
|
||||
|
||||
static $cache = array();
|
||||
|
||||
// GUESS THE LINKED TABLE.. (if found - recursevly call self)
|
||||
|
||||
if ($table == false) {
|
||||
|
||||
|
||||
$info = $this->linkInfo($field);
|
||||
|
||||
if ($info) {
|
||||
return $this->getLink($field, $info[0], $link === false ? $info[1] : $link );
|
||||
return $this->getLink($field, $info[0], $link === false ? $info[1] : $link);
|
||||
}
|
||||
|
||||
// no links defined.. - use borked BC method...
|
||||
@ -133,9 +128,6 @@ class DB_DataObject_Links
|
||||
}
|
||||
$table = substr($field, 0, $p);
|
||||
return $this->getLink($field, $table);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$tn = is_string($table) ? $table : $table->tableName();
|
||||
@ -158,34 +150,33 @@ class DB_DataObject_Links
|
||||
return $cache[$tn.':'. $link .':'. $this->do->$field];
|
||||
}
|
||||
|
||||
$obj = is_string($table) ? $this->do->factory($tn) : $table;;
|
||||
$obj = is_string($table) ? $this->do->factory($tn) : $table;
|
||||
;
|
||||
|
||||
if (!is_a($obj,'DB_DataObject')) {
|
||||
if (!is_a($obj, 'DB_DataObject')) {
|
||||
$this->do->raiseError(
|
||||
"getLink:Could not find class for row $field, table $tn",
|
||||
DB_DATAOBJECT_ERROR_INVALIDCONFIG);
|
||||
DB_DATAOBJECT_ERROR_INVALIDCONFIG
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// -1 or 0 -- no referenced record..
|
||||
|
||||
$ret = false;
|
||||
if ($link) {
|
||||
|
||||
if ($obj->get($link, $this->do->$field)) {
|
||||
$ret = $obj;
|
||||
}
|
||||
|
||||
|
||||
// this really only happens when no link config is set (old BC stuff)
|
||||
} else if ($obj->get($this->do->$field)) {
|
||||
} elseif ($obj->get($this->do->$field)) {
|
||||
$ret= $obj;
|
||||
|
||||
}
|
||||
if ($this->cached) {
|
||||
$cache[$tn.':'. $link .':'. $this->do->$field] = $ret;
|
||||
}
|
||||
return $ret;
|
||||
|
||||
}
|
||||
/**
|
||||
* get link information for a field or field specification
|
||||
@ -201,9 +192,8 @@ class DB_DataObject_Links
|
||||
*
|
||||
*/
|
||||
|
||||
function linkInfo($field)
|
||||
public function linkInfo($field)
|
||||
{
|
||||
|
||||
if (is_array($field)) {
|
||||
if (count($field) == 3) {
|
||||
// array with 3 args:
|
||||
@ -213,37 +203,33 @@ class DB_DataObject_Links
|
||||
$field[2],
|
||||
$field[0]
|
||||
);
|
||||
|
||||
}
|
||||
list($table,$link) = explode(':', $field[1]);
|
||||
list($table, $link) = explode(':', $field[1]);
|
||||
|
||||
return array(
|
||||
$this->do->factory($table),
|
||||
$link,
|
||||
$field[0]
|
||||
);
|
||||
|
||||
}
|
||||
// work out the link.. (classic way)
|
||||
|
||||
$links = $this->do->links();
|
||||
|
||||
if (empty($links) || !is_array($links)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!isset($links[$field])) {
|
||||
|
||||
return false;
|
||||
}
|
||||
list($table,$link) = explode(':', $links[$field]);
|
||||
list($table, $link) = explode(':', $links[$field]);
|
||||
|
||||
|
||||
//??? needed???
|
||||
if ($p = strpos($field,".")) {
|
||||
$field = substr($field,0,$p);
|
||||
if ($p = strpos($field, ".")) {
|
||||
$field = substr($field, 0, $p);
|
||||
}
|
||||
|
||||
return array(
|
||||
@ -251,10 +237,6 @@ class DB_DataObject_Links
|
||||
$link,
|
||||
$field
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -277,14 +259,15 @@ class DB_DataObject_Links
|
||||
* @return mixed true of false on set, the object on getter.
|
||||
*
|
||||
*/
|
||||
function link($field, $args = array())
|
||||
public function link($field, $args = array())
|
||||
{
|
||||
$info = $this->linkInfo($field);
|
||||
|
||||
if (!$info) {
|
||||
$this->do->raiseError(
|
||||
"getLink:Could not find link for row $field",
|
||||
DB_DATAOBJECT_ERROR_INVALIDCONFIG);
|
||||
DB_DATAOBJECT_ERROR_INVALIDCONFIG
|
||||
);
|
||||
return false;
|
||||
}
|
||||
$field = $info[2];
|
||||
@ -299,24 +282,20 @@ class DB_DataObject_Links
|
||||
$ret = $this->getLink($field);
|
||||
// nothing linked -- return new object..
|
||||
return ($ret === 0) ? $info[0] : $ret;
|
||||
|
||||
}
|
||||
$assign = is_array($args) ? $args[0] : $args;
|
||||
|
||||
// otherwise it's a set call..
|
||||
if (!is_a($assign , 'DB_DataObject')) {
|
||||
|
||||
if (!is_a($assign, 'DB_DataObject')) {
|
||||
if (is_numeric($assign) && is_integer($assign * 1)) {
|
||||
if ($assign > 0) {
|
||||
|
||||
if (!$info) {
|
||||
return false;
|
||||
}
|
||||
// check that record exists..
|
||||
if (!$info[0]->get($info[1], $assign )) {
|
||||
if (!$info[0]->get($info[1], $assign)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->do->$field = $assign ;
|
||||
@ -330,8 +309,6 @@ class DB_DataObject_Links
|
||||
|
||||
$this->do->$field = $assign->{$info[1]};
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* load related objects
|
||||
@ -351,7 +328,7 @@ class DB_DataObject_Links
|
||||
* @return boolean , true on success
|
||||
*/
|
||||
|
||||
function applyLinks($format = '_%s')
|
||||
public function applyLinks($format = '_%s')
|
||||
{
|
||||
|
||||
// get table will load the options.
|
||||
@ -366,11 +343,11 @@ class DB_DataObject_Links
|
||||
$loaded = array();
|
||||
|
||||
if ($links) {
|
||||
foreach($links as $key => $match) {
|
||||
list($table,$link) = explode(':', $match);
|
||||
foreach ($links as $key => $match) {
|
||||
list($table, $link) = explode(':', $match);
|
||||
$k = sprintf($format, str_replace('.', '_', $key));
|
||||
// makes sure that '.' is the end of the key;
|
||||
if ($p = strpos($key,'.')) {
|
||||
if ($p = strpos($key, '.')) {
|
||||
$key = substr($key, 0, $p);
|
||||
}
|
||||
|
||||
@ -434,13 +411,10 @@ class DB_DataObject_Links
|
||||
* }
|
||||
*
|
||||
*/
|
||||
function getLinkArray($field, $table = null, $fkey = false, $fval = false, $fmethod = false)
|
||||
public function getLinkArray($field, $table = null, $fkey = false, $fval = false, $fmethod = false)
|
||||
{
|
||||
|
||||
$ret = array();
|
||||
if (!$table) {
|
||||
|
||||
|
||||
$links = $this->do->links();
|
||||
|
||||
if (is_array($links)) {
|
||||
@ -448,20 +422,18 @@ class DB_DataObject_Links
|
||||
// failed..
|
||||
return $ret;
|
||||
}
|
||||
list($table,$link) = explode(':',$links[$field]);
|
||||
return $this->getLinkArray($field,$table);
|
||||
list($table, $link) = explode(':', $links[$field]);
|
||||
return $this->getLinkArray($field, $table);
|
||||
}
|
||||
if (!($p = strpos($field,'_'))) {
|
||||
if (!($p = strpos($field, '_'))) {
|
||||
return $ret;
|
||||
}
|
||||
return $this->getLinkArray($field,substr($field,0,$p));
|
||||
|
||||
|
||||
return $this->getLinkArray($field, substr($field, 0, $p));
|
||||
}
|
||||
|
||||
$c = $this->do->factory($table);
|
||||
|
||||
if (!is_object($c) || !is_a($c,'DB_DataObject')) {
|
||||
if (!is_object($c) || !is_a($c, 'DB_DataObject')) {
|
||||
$this->do->raiseError(
|
||||
"getLinkArray:Could not find class for row $field, table $table",
|
||||
DB_DATAOBJECT_ERROR_INVALIDCONFIG
|
||||
@ -478,8 +450,5 @@ class DB_DataObject_Links
|
||||
return $ret;
|
||||
}
|
||||
return $c->fetchAll($fkey, $fval, $fmethod);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,7 @@
|
||||
// since this version doesnt use overload,
|
||||
// and I assume anyone using custom generators should add this..
|
||||
|
||||
define('DB_DATAOBJECT_NO_OVERLOAD',1);
|
||||
define('DB_DATAOBJECT_NO_OVERLOAD', 1);
|
||||
|
||||
//require_once 'DB/DataObject/Generator.php';
|
||||
require_once 'DB/DataObject/Generator.php';
|
||||
@ -42,13 +42,13 @@ if (!@$_SERVER['argv'][1]) {
|
||||
}
|
||||
|
||||
$config = parse_ini_file($_SERVER['argv'][1], true);
|
||||
foreach($config as $class=>$values) {
|
||||
$options = &PEAR::getStaticProperty($class,'options');
|
||||
foreach ($config as $class=>$values) {
|
||||
$options = &PEAR::getStaticProperty($class, 'options');
|
||||
$options = $values;
|
||||
}
|
||||
|
||||
|
||||
$options = &PEAR::getStaticProperty('DB_DataObject','options');
|
||||
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
||||
if (empty($options)) {
|
||||
PEAR::raiseError("\nERROR: could not read ini file\n\n", null, PEAR_ERROR_DIE);
|
||||
exit;
|
||||
@ -60,4 +60,3 @@ DB_DataObject::debugLevel(isset($options['debug']) ? $options['debug'] : 1);
|
||||
|
||||
$generator = new DB_DataObject_Generator;
|
||||
$generator->start();
|
||||
|
||||
|
@ -53,7 +53,7 @@ class DB_common extends PEAR
|
||||
* The current default fetch mode
|
||||
* @var integer
|
||||
*/
|
||||
var $fetchmode = DB_FETCHMODE_ORDERED;
|
||||
public $fetchmode = DB_FETCHMODE_ORDERED;
|
||||
|
||||
/**
|
||||
* The name of the class into which results should be fetched when
|
||||
@ -61,20 +61,20 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $fetchmode_object_class = 'stdClass';
|
||||
public $fetchmode_object_class = 'stdClass';
|
||||
|
||||
/**
|
||||
* Was a connection present when the object was serialized()?
|
||||
* @var bool
|
||||
* @see DB_common::__sleep(), DB_common::__wake()
|
||||
*/
|
||||
var $was_connected = null;
|
||||
public $was_connected = null;
|
||||
|
||||
/**
|
||||
* The most recently executed query
|
||||
* @var string
|
||||
*/
|
||||
var $last_query = '';
|
||||
public $last_query = '';
|
||||
|
||||
/**
|
||||
* Run-time configuration options
|
||||
@ -85,7 +85,7 @@ class DB_common extends PEAR
|
||||
* @var array
|
||||
* @see DB_common::setOption()
|
||||
*/
|
||||
var $options = array(
|
||||
public $options = array(
|
||||
'result_buffering' => 500,
|
||||
'persistent' => false,
|
||||
'ssl' => false,
|
||||
@ -101,32 +101,32 @@ class DB_common extends PEAR
|
||||
* @var array
|
||||
* @since Property available since Release 1.7.0
|
||||
*/
|
||||
var $last_parameters = array();
|
||||
public $last_parameters = array();
|
||||
|
||||
/**
|
||||
* The elements from each prepared statement
|
||||
* @var array
|
||||
*/
|
||||
var $prepare_tokens = array();
|
||||
public $prepare_tokens = array();
|
||||
|
||||
/**
|
||||
* The data types of the various elements in each prepared statement
|
||||
* @var array
|
||||
*/
|
||||
var $prepare_types = array();
|
||||
public $prepare_types = array();
|
||||
|
||||
/**
|
||||
* The prepared queries
|
||||
* @var array
|
||||
*/
|
||||
var $prepared_queries = array();
|
||||
public $prepared_queries = array();
|
||||
|
||||
/**
|
||||
* Flag indicating that the last query was a manipulation query.
|
||||
* @access protected
|
||||
* @var boolean
|
||||
*/
|
||||
var $_last_query_manip = false;
|
||||
public $_last_query_manip = false;
|
||||
|
||||
/**
|
||||
* Flag indicating that the next query <em>must</em> be a manipulation
|
||||
@ -134,7 +134,7 @@ class DB_common extends PEAR
|
||||
* @access protected
|
||||
* @var boolean
|
||||
*/
|
||||
var $_next_query_manip = false;
|
||||
public $_next_query_manip = false;
|
||||
|
||||
|
||||
// }}}
|
||||
@ -145,7 +145,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
$this->PEAR('DB_Error');
|
||||
}
|
||||
@ -159,7 +159,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return array the array of properties names that should be saved
|
||||
*/
|
||||
function __sleep()
|
||||
public function __sleep()
|
||||
{
|
||||
if ($this->connection) {
|
||||
// Don't disconnect(), people use serialize() for many reasons
|
||||
@ -201,7 +201,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __wakeup()
|
||||
public function __wakeup()
|
||||
{
|
||||
if ($this->was_connected) {
|
||||
$this->connect($this->dsn, $this->options['persistent']);
|
||||
@ -218,7 +218,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @since Method available since Release 1.7.0
|
||||
*/
|
||||
function __toString()
|
||||
public function __toString()
|
||||
{
|
||||
$info = strtolower(get_class($this));
|
||||
$info .= ': (phptype=' . $this->phptype .
|
||||
@ -240,7 +240,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @deprecated Method deprecated in Release 1.7.0
|
||||
*/
|
||||
function toString()
|
||||
public function toString()
|
||||
{
|
||||
return $this->__toString();
|
||||
}
|
||||
@ -259,7 +259,7 @@ class DB_common extends PEAR
|
||||
* @see DB_common::quoteSmart(), DB_common::escapeSimple()
|
||||
* @deprecated Method deprecated some time before Release 1.2
|
||||
*/
|
||||
function quoteString($string)
|
||||
public function quoteString($string)
|
||||
{
|
||||
$string = $this->quoteSmart($string);
|
||||
if ($string{0} == "'") {
|
||||
@ -282,7 +282,7 @@ class DB_common extends PEAR
|
||||
* @see DB_common::quoteSmart(), DB_common::escapeSimple()
|
||||
* @deprecated Deprecated in release 1.6.0
|
||||
*/
|
||||
function quote($string = null)
|
||||
public function quote($string = null)
|
||||
{
|
||||
return $this->quoteSmart($string);
|
||||
}
|
||||
@ -327,7 +327,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function quoteIdentifier($str)
|
||||
public function quoteIdentifier($str)
|
||||
{
|
||||
return '"' . str_replace('"', '""', $str) . '"';
|
||||
}
|
||||
@ -436,7 +436,7 @@ class DB_common extends PEAR
|
||||
* @see DB_common::escapeSimple()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function quoteSmart($in)
|
||||
public function quoteSmart($in)
|
||||
{
|
||||
if (is_int($in)) {
|
||||
return $in;
|
||||
@ -448,8 +448,7 @@ class DB_common extends PEAR
|
||||
return 'NULL';
|
||||
} else {
|
||||
if ($this->dbsyntax == 'access'
|
||||
&& preg_match('/^#.+#$/', $in))
|
||||
{
|
||||
&& preg_match('/^#.+#$/', $in)) {
|
||||
return $this->escapeSimple($in);
|
||||
}
|
||||
return "'" . $this->escapeSimple($in) . "'";
|
||||
@ -468,7 +467,8 @@ class DB_common extends PEAR
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since release 1.7.8.
|
||||
*/
|
||||
function quoteBoolean($boolean) {
|
||||
public function quoteBoolean($boolean)
|
||||
{
|
||||
return $boolean ? '1' : '0';
|
||||
}
|
||||
|
||||
@ -484,7 +484,8 @@ class DB_common extends PEAR
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since release 1.7.8.
|
||||
*/
|
||||
function quoteFloat($float) {
|
||||
public function quoteFloat($float)
|
||||
{
|
||||
return "'".$this->escapeSimple(str_replace(',', '.', strval(floatval($float))))."'";
|
||||
}
|
||||
|
||||
@ -506,7 +507,7 @@ class DB_common extends PEAR
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function escapeSimple($str)
|
||||
public function escapeSimple($str)
|
||||
{
|
||||
return str_replace("'", "''", $str);
|
||||
}
|
||||
@ -521,7 +522,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return bool whether this driver supports $feature
|
||||
*/
|
||||
function provides($feature)
|
||||
public function provides($feature)
|
||||
{
|
||||
return $this->features[$feature];
|
||||
}
|
||||
@ -544,11 +545,12 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @see DB_FETCHMODE_ORDERED, DB_FETCHMODE_ASSOC, DB_FETCHMODE_OBJECT
|
||||
*/
|
||||
function setFetchMode($fetchmode, $object_class = 'stdClass')
|
||||
public function setFetchMode($fetchmode, $object_class = 'stdClass')
|
||||
{
|
||||
switch ($fetchmode) {
|
||||
case DB_FETCHMODE_OBJECT:
|
||||
$this->fetchmode_object_class = $object_class;
|
||||
// no break
|
||||
case DB_FETCHMODE_ORDERED:
|
||||
case DB_FETCHMODE_ASSOC:
|
||||
$this->fetchmode = $fetchmode;
|
||||
@ -699,7 +701,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @see DB_common::$options
|
||||
*/
|
||||
function setOption($option, $value)
|
||||
public function setOption($option, $value)
|
||||
{
|
||||
if (isset($this->options[$option])) {
|
||||
$this->options[$option] = $value;
|
||||
@ -744,7 +746,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return mixed the option's value
|
||||
*/
|
||||
function getOption($option)
|
||||
public function getOption($option)
|
||||
{
|
||||
if (isset($this->options[$option])) {
|
||||
return $this->options[$option];
|
||||
@ -798,10 +800,14 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @see DB_common::execute()
|
||||
*/
|
||||
function prepare($query)
|
||||
public function prepare($query)
|
||||
{
|
||||
$tokens = preg_split('/((?<!\\\)[&?!])/', $query, -1,
|
||||
PREG_SPLIT_DELIM_CAPTURE);
|
||||
$tokens = preg_split(
|
||||
'/((?<!\\\)[&?!])/',
|
||||
$query,
|
||||
-1,
|
||||
PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
$token = 0;
|
||||
$types = array();
|
||||
$newtokens = array();
|
||||
@ -850,9 +856,12 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @uses DB_common::prepare(), DB_common::buildManipSQL()
|
||||
*/
|
||||
function autoPrepare($table, $table_fields, $mode = DB_AUTOQUERY_INSERT,
|
||||
$where = false)
|
||||
{
|
||||
public function autoPrepare(
|
||||
$table,
|
||||
$table_fields,
|
||||
$mode = DB_AUTOQUERY_INSERT,
|
||||
$where = false
|
||||
) {
|
||||
$query = $this->buildManipSQL($table, $table_fields, $mode, $where);
|
||||
if (DB::isError($query)) {
|
||||
return $query;
|
||||
@ -882,18 +891,24 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @uses DB_common::autoPrepare(), DB_common::execute()
|
||||
*/
|
||||
function autoExecute($table, $fields_values, $mode = DB_AUTOQUERY_INSERT,
|
||||
$where = false)
|
||||
{
|
||||
$sth = $this->autoPrepare($table, array_keys($fields_values), $mode,
|
||||
$where);
|
||||
public function autoExecute(
|
||||
$table,
|
||||
$fields_values,
|
||||
$mode = DB_AUTOQUERY_INSERT,
|
||||
$where = false
|
||||
) {
|
||||
$sth = $this->autoPrepare(
|
||||
$table,
|
||||
array_keys($fields_values),
|
||||
$mode,
|
||||
$where
|
||||
);
|
||||
if (DB::isError($sth)) {
|
||||
return $sth;
|
||||
}
|
||||
$ret = $this->execute($sth, array_values($fields_values));
|
||||
$this->freePrepared($sth);
|
||||
return $ret;
|
||||
|
||||
}
|
||||
|
||||
// }}}
|
||||
@ -929,7 +944,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return string the sql query for autoPrepare()
|
||||
*/
|
||||
function buildManipSQL($table, $table_fields, $mode, $where = false)
|
||||
public function buildManipSQL($table, $table_fields, $mode, $where = false)
|
||||
{
|
||||
if (count($table_fields) == 0) {
|
||||
return $this->raiseError(DB_ERROR_NEED_MORE_DATA);
|
||||
@ -1002,7 +1017,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @see DB_common::prepare()
|
||||
*/
|
||||
function &execute($stmt, $data = array())
|
||||
public function &execute($stmt, $data = array())
|
||||
{
|
||||
$realquery = $this->executeEmulateQuery($stmt, $data);
|
||||
if (DB::isError($realquery)) {
|
||||
@ -1037,7 +1052,7 @@ class DB_common extends PEAR
|
||||
* @access protected
|
||||
* @see DB_common::execute()
|
||||
*/
|
||||
function executeEmulateQuery($stmt, $data = array())
|
||||
public function executeEmulateQuery($stmt, $data = array())
|
||||
{
|
||||
$stmt = (int)$stmt;
|
||||
$data = (array)$data;
|
||||
@ -1091,7 +1106,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @see DB_common::prepare(), DB_common::execute()
|
||||
*/
|
||||
function executeMultiple($stmt, $data)
|
||||
public function executeMultiple($stmt, $data)
|
||||
{
|
||||
foreach ($data as $value) {
|
||||
$res = $this->execute($stmt, $value);
|
||||
@ -1117,7 +1132,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @see DB_common::prepare()
|
||||
*/
|
||||
function freePrepared($stmt, $free_resource = true)
|
||||
public function freePrepared($stmt, $free_resource = true)
|
||||
{
|
||||
$stmt = (int)$stmt;
|
||||
if (isset($this->prepare_tokens[$stmt])) {
|
||||
@ -1145,7 +1160,7 @@ class DB_common extends PEAR
|
||||
* @see DB_mysql::modifyQuery(), DB_oci8::modifyQuery(),
|
||||
* DB_sqlite::modifyQuery()
|
||||
*/
|
||||
function modifyQuery($query)
|
||||
public function modifyQuery($query)
|
||||
{
|
||||
return $query;
|
||||
}
|
||||
@ -1172,7 +1187,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
{
|
||||
return $query;
|
||||
}
|
||||
@ -1200,7 +1215,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @see DB_result, DB_common::prepare(), DB_common::execute()
|
||||
*/
|
||||
function &query($query, $params = array())
|
||||
public function &query($query, $params = array())
|
||||
{
|
||||
if (sizeof($params) > 0) {
|
||||
$sth = $this->prepare($query);
|
||||
@ -1241,10 +1256,10 @@ class DB_common extends PEAR
|
||||
* or DB_OK for successul data manipulation queries.
|
||||
* A DB_Error object on failure.
|
||||
*/
|
||||
function &limitQuery($query, $from, $count, $params = array())
|
||||
public function &limitQuery($query, $from, $count, $params = array())
|
||||
{
|
||||
$query = $this->modifyLimitQuery($query, $from, $count, $params);
|
||||
if (DB::isError($query)){
|
||||
if (DB::isError($query)) {
|
||||
return $query;
|
||||
}
|
||||
$result = $this->query($query, $params);
|
||||
@ -1273,7 +1288,7 @@ class DB_common extends PEAR
|
||||
* @return mixed the returned value of the query.
|
||||
* A DB_Error object on failure.
|
||||
*/
|
||||
function &getOne($query, $params = array())
|
||||
public function &getOne($query, $params = array())
|
||||
{
|
||||
$params = (array)$params;
|
||||
// modifyLimitQuery() would be nice here, but it causes BC issues
|
||||
@ -1321,9 +1336,11 @@ class DB_common extends PEAR
|
||||
* @return array the first row of results as an array.
|
||||
* A DB_Error object on failure.
|
||||
*/
|
||||
function &getRow($query, $params = array(),
|
||||
$fetchmode = DB_FETCHMODE_DEFAULT)
|
||||
{
|
||||
public function &getRow(
|
||||
$query,
|
||||
$params = array(),
|
||||
$fetchmode = DB_FETCHMODE_DEFAULT
|
||||
) {
|
||||
// compat check, the params and fetchmode parameters used to
|
||||
// have the opposite order
|
||||
if (!is_array($params)) {
|
||||
@ -1387,7 +1404,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @see DB_common::query()
|
||||
*/
|
||||
function &getCol($query, $col = 0, $params = array())
|
||||
public function &getCol($query, $col = 0, $params = array())
|
||||
{
|
||||
$params = (array)$params;
|
||||
if (sizeof($params) > 0) {
|
||||
@ -1518,9 +1535,13 @@ class DB_common extends PEAR
|
||||
* @return array the associative array containing the query results.
|
||||
* A DB_Error object on failure.
|
||||
*/
|
||||
function &getAssoc($query, $force_array = false, $params = array(),
|
||||
$fetchmode = DB_FETCHMODE_DEFAULT, $group = false)
|
||||
{
|
||||
public function &getAssoc(
|
||||
$query,
|
||||
$force_array = false,
|
||||
$params = array(),
|
||||
$fetchmode = DB_FETCHMODE_DEFAULT,
|
||||
$group = false
|
||||
) {
|
||||
$params = (array)$params;
|
||||
if (sizeof($params) > 0) {
|
||||
$sth = $this->prepare($query);
|
||||
@ -1629,9 +1650,11 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return array the nested array. A DB_Error object on failure.
|
||||
*/
|
||||
function &getAll($query, $params = array(),
|
||||
$fetchmode = DB_FETCHMODE_DEFAULT)
|
||||
{
|
||||
public function &getAll(
|
||||
$query,
|
||||
$params = array(),
|
||||
$fetchmode = DB_FETCHMODE_DEFAULT
|
||||
) {
|
||||
// compat check, the params and fetchmode parameters used to
|
||||
// have the opposite order
|
||||
if (!is_array($params)) {
|
||||
@ -1697,7 +1720,7 @@ class DB_common extends PEAR
|
||||
* @return int DB_OK on success. A DB_Error object if the driver
|
||||
* doesn't support auto-committing transactions.
|
||||
*/
|
||||
function autoCommit($onoff = false)
|
||||
public function autoCommit($onoff = false)
|
||||
{
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
@ -1710,7 +1733,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function commit()
|
||||
public function commit()
|
||||
{
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
@ -1723,7 +1746,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function rollback()
|
||||
public function rollback()
|
||||
{
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
@ -1738,7 +1761,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function numRows($result)
|
||||
public function numRows($result)
|
||||
{
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
@ -1753,7 +1776,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
@ -1775,10 +1798,12 @@ class DB_common extends PEAR
|
||||
* @see DB_common::createSequence(), DB_common::dropSequence(),
|
||||
* DB_common::nextID(), DB_common::setOption()
|
||||
*/
|
||||
function getSequenceName($sqn)
|
||||
public function getSequenceName($sqn)
|
||||
{
|
||||
return sprintf($this->getOption('seqname_format'),
|
||||
preg_replace('/[^a-z0-9_.]/i', '_', $sqn));
|
||||
return sprintf(
|
||||
$this->getOption('seqname_format'),
|
||||
preg_replace('/[^a-z0-9_.]/i', '_', $sqn)
|
||||
);
|
||||
}
|
||||
|
||||
// }}}
|
||||
@ -1797,7 +1822,7 @@ class DB_common extends PEAR
|
||||
* @see DB_common::createSequence(), DB_common::dropSequence(),
|
||||
* DB_common::getSequenceName()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
@ -1822,7 +1847,7 @@ class DB_common extends PEAR
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_common::nextID()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
@ -1840,7 +1865,7 @@ class DB_common extends PEAR
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_common::nextID()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
@ -1876,10 +1901,15 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @see PEAR_Error
|
||||
*/
|
||||
function &raiseError($code = DB_ERROR, $mode = null, $options = null,
|
||||
$userinfo = null, $nativecode = null, $dummy1 = null,
|
||||
$dummy2 = null)
|
||||
{
|
||||
public function &raiseError(
|
||||
$code = DB_ERROR,
|
||||
$mode = null,
|
||||
$options = null,
|
||||
$userinfo = null,
|
||||
$nativecode = null,
|
||||
$dummy1 = null,
|
||||
$dummy2 = null
|
||||
) {
|
||||
// The error is yet a DB error object
|
||||
if (is_object($code)) {
|
||||
// because we the static PEAR::raiseError, our global
|
||||
@ -1888,8 +1918,15 @@ class DB_common extends PEAR
|
||||
$mode = $this->_default_error_mode;
|
||||
$options = $this->_default_error_options;
|
||||
}
|
||||
$tmp = PEAR::raiseError($code, null, $mode, $options,
|
||||
null, null, true);
|
||||
$tmp = PEAR::raiseError(
|
||||
$code,
|
||||
null,
|
||||
$mode,
|
||||
$options,
|
||||
null,
|
||||
null,
|
||||
true
|
||||
);
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
@ -1903,8 +1940,15 @@ class DB_common extends PEAR
|
||||
$userinfo .= ' [DB Error: ' . DB::errorMessage($code) . ']';
|
||||
}
|
||||
|
||||
$tmp = PEAR::raiseError(null, $code, $mode, $options, $userinfo,
|
||||
'DB_Error', true);
|
||||
$tmp = PEAR::raiseError(
|
||||
null,
|
||||
$code,
|
||||
$mode,
|
||||
$options,
|
||||
$userinfo,
|
||||
'DB_Error',
|
||||
true
|
||||
);
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
@ -1916,7 +1960,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @return mixed the DBMS' error code. A DB_Error object on failure.
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
@ -1935,7 +1979,7 @@ class DB_common extends PEAR
|
||||
* current driver doesn't have a mapping for the
|
||||
* $nativecode submitted.
|
||||
*/
|
||||
function errorCode($nativecode)
|
||||
public function errorCode($nativecode)
|
||||
{
|
||||
if (isset($this->errorcode_map[$nativecode])) {
|
||||
return $this->errorcode_map[$nativecode];
|
||||
@ -1957,7 +2001,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @see DB::errorMessage()
|
||||
*/
|
||||
function errorMessage($dbcode)
|
||||
public function errorMessage($dbcode)
|
||||
{
|
||||
return DB::errorMessage($this->errorcode_map[$dbcode]);
|
||||
}
|
||||
@ -2085,7 +2129,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @see DB_common::setOption()
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
/*
|
||||
* If the DB_<driver> class has a tableInfo() method, that one
|
||||
@ -2105,7 +2149,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @deprecated Method deprecated some time before Release 1.2
|
||||
*/
|
||||
function getTables()
|
||||
public function getTables()
|
||||
{
|
||||
return $this->getListOf('tables');
|
||||
}
|
||||
@ -2124,7 +2168,7 @@ class DB_common extends PEAR
|
||||
* @return array an array listing the items sought.
|
||||
* A DB DB_Error object on failure.
|
||||
*/
|
||||
function getListOf($type)
|
||||
public function getListOf($type)
|
||||
{
|
||||
$sql = $this->getSpecialQuery($type);
|
||||
if ($sql === null) {
|
||||
@ -2155,7 +2199,7 @@ class DB_common extends PEAR
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
return $this->raiseError(DB_ERROR_UNSUPPORTED);
|
||||
}
|
||||
@ -2174,7 +2218,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function nextQueryIsManip($manip)
|
||||
public function nextQueryIsManip($manip)
|
||||
{
|
||||
$this->_next_query_manip = $manip;
|
||||
}
|
||||
@ -2194,7 +2238,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function _checkManip($query)
|
||||
public function _checkManip($query)
|
||||
{
|
||||
if ($this->_next_query_manip || DB::isManip($query)) {
|
||||
$this->_last_query_manip = true;
|
||||
@ -2218,7 +2262,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function _rtrimArrayValues(&$array)
|
||||
public function _rtrimArrayValues(&$array)
|
||||
{
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
@ -2239,7 +2283,7 @@ class DB_common extends PEAR
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function _convertNullArrayValuesToEmpty(&$array)
|
||||
public function _convertNullArrayValuesToEmpty(&$array)
|
||||
{
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_null($value)) {
|
||||
@ -2257,5 +2301,3 @@ class DB_common extends PEAR
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -52,13 +52,13 @@ class DB_dbase extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'dbase';
|
||||
public $phptype = 'dbase';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'dbase';
|
||||
public $dbsyntax = 'dbase';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -73,7 +73,7 @@ class DB_dbase extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => false,
|
||||
'new_link' => false,
|
||||
'numrows' => true,
|
||||
@ -87,27 +87,27 @@ class DB_dbase extends DB_common
|
||||
* A mapping of native error codes to DB error codes
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
);
|
||||
|
||||
/**
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
* A means of emulating result resources
|
||||
* @var array
|
||||
*/
|
||||
var $res_row = array();
|
||||
public $res_row = array();
|
||||
|
||||
/**
|
||||
* The quantity of results so far
|
||||
@ -116,7 +116,7 @@ class DB_dbase extends DB_common
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
var $result = 0;
|
||||
public $result = 0;
|
||||
|
||||
/**
|
||||
* Maps dbase data type id's to human readable strings
|
||||
@ -127,7 +127,7 @@ class DB_dbase extends DB_common
|
||||
* @var array
|
||||
* @since Property available since Release 1.7.0
|
||||
*/
|
||||
var $types = array(
|
||||
public $types = array(
|
||||
'C' => 'character',
|
||||
'D' => 'date',
|
||||
'L' => 'boolean',
|
||||
@ -144,7 +144,7 @@ class DB_dbase extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -199,7 +199,7 @@ class DB_dbase extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('dbase')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
@ -220,32 +220,48 @@ class DB_dbase extends DB_common
|
||||
if (!file_exists($dsn['database'])) {
|
||||
$this->dsn['mode'] = 2;
|
||||
if (empty($dsn['fields']) || !is_array($dsn['fields'])) {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
'the dbase file does not exist and '
|
||||
. 'it could not be created because '
|
||||
. 'the "fields" element of the DSN '
|
||||
. 'is not properly set');
|
||||
. 'is not properly set'
|
||||
);
|
||||
}
|
||||
$this->connection = @dbase_create($dsn['database'],
|
||||
$dsn['fields']);
|
||||
$this->connection = @dbase_create(
|
||||
$dsn['database'],
|
||||
$dsn['fields']
|
||||
);
|
||||
if (!$this->connection) {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
'the dbase file does not exist and '
|
||||
. 'the attempt to create it failed: '
|
||||
. $php_errormsg);
|
||||
. $php_errormsg
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (!isset($this->dsn['mode'])) {
|
||||
$this->dsn['mode'] = 0;
|
||||
}
|
||||
$this->connection = @dbase_open($dsn['database'],
|
||||
$this->dsn['mode']);
|
||||
$this->connection = @dbase_open(
|
||||
$dsn['database'],
|
||||
$this->dsn['mode']
|
||||
);
|
||||
if (!$this->connection) {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$php_errormsg);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$php_errormsg
|
||||
);
|
||||
}
|
||||
}
|
||||
return DB_OK;
|
||||
@ -259,7 +275,7 @@ class DB_dbase extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$ret = @dbase_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -269,7 +285,7 @@ class DB_dbase extends DB_common
|
||||
// }}}
|
||||
// {{{ &query()
|
||||
|
||||
function &query($query = null)
|
||||
public function &query($query = null)
|
||||
{
|
||||
// emulate result resources
|
||||
$this->res_row[(int)$this->result] = 0;
|
||||
@ -300,7 +316,7 @@ class DB_dbase extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
if ($rownum === null) {
|
||||
$rownum = $this->res_row[(int)$result]++;
|
||||
@ -340,7 +356,7 @@ class DB_dbase extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -361,7 +377,7 @@ class DB_dbase extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($foo)
|
||||
public function numCols($foo)
|
||||
{
|
||||
return @dbase_numfields($this->connection);
|
||||
}
|
||||
@ -382,7 +398,7 @@ class DB_dbase extends DB_common
|
||||
*
|
||||
* @see DB_result::numRows()
|
||||
*/
|
||||
function numRows($foo)
|
||||
public function numRows($foo)
|
||||
{
|
||||
return @dbase_numrecords($this->connection);
|
||||
}
|
||||
@ -399,7 +415,8 @@ class DB_dbase extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since release 1.7.8.
|
||||
*/
|
||||
function quoteBoolean($boolean) {
|
||||
public function quoteBoolean($boolean)
|
||||
{
|
||||
return $boolean ? 'T' : 'F';
|
||||
}
|
||||
|
||||
@ -419,14 +436,18 @@ class DB_dbase extends DB_common
|
||||
* @see DB_common::tableInfo()
|
||||
* @since Method available since Release 1.7.0
|
||||
*/
|
||||
function tableInfo($result = null, $mode = null)
|
||||
public function tableInfo($result = null, $mode = null)
|
||||
{
|
||||
if (function_exists('dbase_get_header_info')) {
|
||||
$id = @dbase_get_header_info($this->connection);
|
||||
if (!$id && $php_errormsg) {
|
||||
return $this->raiseError(DB_ERROR,
|
||||
null, null, null,
|
||||
$php_errormsg);
|
||||
return $this->raiseError(
|
||||
DB_ERROR,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$php_errormsg
|
||||
);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
@ -436,9 +457,13 @@ class DB_dbase extends DB_common
|
||||
*/
|
||||
$db = @fopen($this->dsn['database'], 'r');
|
||||
if (!$db) {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$php_errormsg);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$php_errormsg
|
||||
);
|
||||
}
|
||||
|
||||
$id = array();
|
||||
@ -506,5 +531,3 @@ class DB_dbase extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -53,13 +53,13 @@ class DB_fbsql extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'fbsql';
|
||||
public $phptype = 'fbsql';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'fbsql';
|
||||
public $dbsyntax = 'fbsql';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -74,7 +74,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => 'alter',
|
||||
'new_link' => false,
|
||||
'numrows' => true,
|
||||
@ -88,7 +88,7 @@ class DB_fbsql extends DB_common
|
||||
* A mapping of native error codes to DB error codes
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
22 => DB_ERROR_SYNTAX,
|
||||
85 => DB_ERROR_ALREADY_EXISTS,
|
||||
108 => DB_ERROR_SYNTAX,
|
||||
@ -111,13 +111,13 @@ class DB_fbsql extends DB_common
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
// }}}
|
||||
@ -128,7 +128,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -146,7 +146,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('fbsql')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
@ -168,19 +168,27 @@ class DB_fbsql extends DB_common
|
||||
$ini = ini_get('track_errors');
|
||||
$php_errormsg = '';
|
||||
if ($ini) {
|
||||
$this->connection = @call_user_func_array($connect_function,
|
||||
$params);
|
||||
$this->connection = @call_user_func_array(
|
||||
$connect_function,
|
||||
$params
|
||||
);
|
||||
} else {
|
||||
@ini_set('track_errors', 1);
|
||||
$this->connection = @call_user_func_array($connect_function,
|
||||
$params);
|
||||
$this->connection = @call_user_func_array(
|
||||
$connect_function,
|
||||
$params
|
||||
);
|
||||
@ini_set('track_errors', $ini);
|
||||
}
|
||||
|
||||
if (!$this->connection) {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$php_errormsg);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$php_errormsg
|
||||
);
|
||||
}
|
||||
|
||||
if ($dsn['database']) {
|
||||
@ -200,7 +208,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$ret = @fbsql_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -219,7 +227,7 @@ class DB_fbsql extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$this->last_query = $query;
|
||||
$query = $this->modifyQuery($query);
|
||||
@ -247,7 +255,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @return true if a result is available otherwise return false
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return @fbsql_next_result($result);
|
||||
}
|
||||
@ -275,7 +283,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
if ($rownum !== null) {
|
||||
if (!@fbsql_data_seek($result, $rownum)) {
|
||||
@ -318,7 +326,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
return is_resource($result) ? fbsql_free_result($result) : false;
|
||||
}
|
||||
@ -334,7 +342,7 @@ class DB_fbsql extends DB_common
|
||||
* @return int DB_OK on success. A DB_Error object if the driver
|
||||
* doesn't support auto-committing transactions.
|
||||
*/
|
||||
function autoCommit($onoff=false)
|
||||
public function autoCommit($onoff=false)
|
||||
{
|
||||
if ($onoff) {
|
||||
$this->query("SET COMMIT TRUE");
|
||||
@ -351,7 +359,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function commit()
|
||||
public function commit()
|
||||
{
|
||||
@fbsql_commit($this->connection);
|
||||
}
|
||||
@ -364,7 +372,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function rollback()
|
||||
public function rollback()
|
||||
{
|
||||
@fbsql_rollback($this->connection);
|
||||
}
|
||||
@ -385,7 +393,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
$cols = @fbsql_num_fields($result);
|
||||
if (!$cols) {
|
||||
@ -410,7 +418,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @see DB_result::numRows()
|
||||
*/
|
||||
function numRows($result)
|
||||
public function numRows($result)
|
||||
{
|
||||
$rows = @fbsql_num_rows($result);
|
||||
if ($rows === null) {
|
||||
@ -429,7 +437,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
if ($this->_last_query_manip) {
|
||||
$result = @fbsql_affected_rows($this->connection);
|
||||
@ -455,7 +463,7 @@ class DB_fbsql extends DB_common
|
||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||
* DB_fbsql::createSequence(), DB_fbsql::dropSequence()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
do {
|
||||
@ -491,7 +499,7 @@ class DB_fbsql extends DB_common
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_fbsql::nextID(), DB_fbsql::dropSequence()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
$res = $this->query('CREATE TABLE ' . $seqname
|
||||
@ -516,7 +524,7 @@ class DB_fbsql extends DB_common
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_fbsql::nextID(), DB_fbsql::createSequence()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name)
|
||||
. ' RESTRICT');
|
||||
@ -541,14 +549,20 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
{
|
||||
if (DB::isManip($query) || $this->_next_query_manip) {
|
||||
return preg_replace('/^([\s(])*SELECT/i',
|
||||
"\\1SELECT TOP($count)", $query);
|
||||
return preg_replace(
|
||||
'/^([\s(])*SELECT/i',
|
||||
"\\1SELECT TOP($count)",
|
||||
$query
|
||||
);
|
||||
} else {
|
||||
return preg_replace('/([\s(])*SELECT/i',
|
||||
"\\1SELECT TOP($from, $count)", $query);
|
||||
return preg_replace(
|
||||
'/([\s(])*SELECT/i',
|
||||
"\\1SELECT TOP($from, $count)",
|
||||
$query
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -564,7 +578,8 @@ class DB_fbsql extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since release 1.7.8.
|
||||
*/
|
||||
function quoteBoolean($boolean) {
|
||||
public function quoteBoolean($boolean)
|
||||
{
|
||||
return $boolean ? 'TRUE' : 'FALSE';
|
||||
}
|
||||
|
||||
@ -580,7 +595,8 @@ class DB_fbsql extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since release 1.7.8.
|
||||
*/
|
||||
function quoteFloat($float) {
|
||||
public function quoteFloat($float)
|
||||
{
|
||||
return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
|
||||
}
|
||||
|
||||
@ -599,13 +615,18 @@ class DB_fbsql extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_fbsql::errorNative(), DB_common::errorCode()
|
||||
*/
|
||||
function fbsqlRaiseError($errno = null)
|
||||
public function fbsqlRaiseError($errno = null)
|
||||
{
|
||||
if ($errno === null) {
|
||||
$errno = $this->errorCode(fbsql_errno($this->connection));
|
||||
}
|
||||
return $this->raiseError($errno, null, null, null,
|
||||
@fbsql_error($this->connection));
|
||||
return $this->raiseError(
|
||||
$errno,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@fbsql_error($this->connection)
|
||||
);
|
||||
}
|
||||
|
||||
// }}}
|
||||
@ -616,7 +637,7 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @return int the DBMS' error code
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
return @fbsql_errno($this->connection);
|
||||
}
|
||||
@ -639,15 +660,18 @@ class DB_fbsql extends DB_common
|
||||
*
|
||||
* @see DB_common::tableInfo()
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
/*
|
||||
* Probably received a table name.
|
||||
* Create a result resource identifier.
|
||||
*/
|
||||
$id = @fbsql_list_fields($this->dsn['database'],
|
||||
$result, $this->connection);
|
||||
$id = @fbsql_list_fields(
|
||||
$this->dsn['database'],
|
||||
$result,
|
||||
$this->connection
|
||||
);
|
||||
$got_string = true;
|
||||
} elseif (isset($result->result)) {
|
||||
/*
|
||||
@ -720,7 +744,7 @@ class DB_fbsql extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'tables':
|
||||
@ -765,5 +789,3 @@ class DB_fbsql extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -61,13 +61,13 @@ class DB_ibase extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'ibase';
|
||||
public $phptype = 'ibase';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'ibase';
|
||||
public $dbsyntax = 'ibase';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -84,7 +84,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => false,
|
||||
'new_link' => false,
|
||||
'numrows' => 'emulate',
|
||||
@ -98,7 +98,7 @@ class DB_ibase extends DB_common
|
||||
* A mapping of native error codes to DB error codes
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
-104 => DB_ERROR_SYNTAX,
|
||||
-150 => DB_ERROR_ACCESS_VIOLATION,
|
||||
-151 => DB_ERROR_ACCESS_VIOLATION,
|
||||
@ -134,13 +134,13 @@ class DB_ibase extends DB_common
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -148,14 +148,14 @@ class DB_ibase extends DB_common
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $affected = 0;
|
||||
public $affected = 0;
|
||||
|
||||
/**
|
||||
* Should data manipulation queries be committed automatically?
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $autocommit = true;
|
||||
public $autocommit = true;
|
||||
|
||||
/**
|
||||
* The prepared statement handle from the most recently executed statement
|
||||
@ -166,14 +166,14 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
var $last_stmt;
|
||||
public $last_stmt;
|
||||
|
||||
/**
|
||||
* Is the given prepared statement a data manipulation query?
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $manip_query = array();
|
||||
public $manip_query = array();
|
||||
|
||||
|
||||
// }}}
|
||||
@ -184,7 +184,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -212,7 +212,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('interbase')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
@ -255,7 +255,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$ret = @ibase_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -274,7 +274,7 @@ class DB_ibase extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$ismanip = $this->_checkManip($query);
|
||||
$this->last_query = $query;
|
||||
@ -317,11 +317,14 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
{
|
||||
if ($this->dsn['dbsyntax'] == 'firebird') {
|
||||
$query = preg_replace('/^([\s(])*SELECT/i',
|
||||
"SELECT FIRST $count SKIP $from", $query);
|
||||
$query = preg_replace(
|
||||
'/^([\s(])*SELECT/i',
|
||||
"SELECT FIRST $count SKIP $from",
|
||||
$query
|
||||
);
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
@ -338,7 +341,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @return true if a result is available otherwise return false
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -366,7 +369,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
if ($rownum !== null) {
|
||||
return $this->ibaseRaiseError(DB_ERROR_NOT_CAPABLE);
|
||||
@ -411,7 +414,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
return is_resource($result) ? ibase_free_result($result) : false;
|
||||
}
|
||||
@ -419,7 +422,7 @@ class DB_ibase extends DB_common
|
||||
// }}}
|
||||
// {{{ freeQuery()
|
||||
|
||||
function freeQuery($query)
|
||||
public function freeQuery($query)
|
||||
{
|
||||
return is_resource($query) ? ibase_free_query($query) : false;
|
||||
}
|
||||
@ -434,7 +437,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
if (is_integer($this->affected)) {
|
||||
return $this->affected;
|
||||
@ -458,7 +461,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
$cols = @ibase_num_fields($result);
|
||||
if (!$cols) {
|
||||
@ -492,10 +495,14 @@ class DB_ibase extends DB_common
|
||||
* @param string $query query to be prepared
|
||||
* @return mixed DB statement resource on success. DB_Error on failure.
|
||||
*/
|
||||
function prepare($query)
|
||||
public function prepare($query)
|
||||
{
|
||||
$tokens = preg_split('/((?<!\\\)[&?!])/', $query, -1,
|
||||
PREG_SPLIT_DELIM_CAPTURE);
|
||||
$tokens = preg_split(
|
||||
'/((?<!\\\)[&?!])/',
|
||||
$query,
|
||||
-1,
|
||||
PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
$token = 0;
|
||||
$types = array();
|
||||
$newquery = '';
|
||||
@ -548,7 +555,7 @@ class DB_ibase extends DB_common
|
||||
* @see DB_ibase::prepare()
|
||||
* @access public
|
||||
*/
|
||||
function &execute($stmt, $data = array())
|
||||
public function &execute($stmt, $data = array())
|
||||
{
|
||||
$data = (array)$data;
|
||||
$this->last_parameters = $data;
|
||||
@ -618,7 +625,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @see DB_ibase::prepare()
|
||||
*/
|
||||
function freePrepared($stmt, $free_resource = true)
|
||||
public function freePrepared($stmt, $free_resource = true)
|
||||
{
|
||||
if (!is_resource($stmt)) {
|
||||
return false;
|
||||
@ -643,7 +650,7 @@ class DB_ibase extends DB_common
|
||||
* @return int DB_OK on success. A DB_Error object if the driver
|
||||
* doesn't support auto-committing transactions.
|
||||
*/
|
||||
function autoCommit($onoff = false)
|
||||
public function autoCommit($onoff = false)
|
||||
{
|
||||
$this->autocommit = $onoff ? 1 : 0;
|
||||
return DB_OK;
|
||||
@ -657,7 +664,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function commit()
|
||||
public function commit()
|
||||
{
|
||||
return @ibase_commit($this->connection);
|
||||
}
|
||||
@ -670,7 +677,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function rollback()
|
||||
public function rollback()
|
||||
{
|
||||
return @ibase_rollback($this->connection);
|
||||
}
|
||||
@ -678,7 +685,7 @@ class DB_ibase extends DB_common
|
||||
// }}}
|
||||
// {{{ transactionInit()
|
||||
|
||||
function transactionInit($trans_args = 0)
|
||||
public function transactionInit($trans_args = 0)
|
||||
{
|
||||
return $trans_args
|
||||
? @ibase_trans($trans_args, $this->connection)
|
||||
@ -701,7 +708,7 @@ class DB_ibase extends DB_common
|
||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||
* DB_ibase::createSequence(), DB_ibase::dropSequence()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
$sqn = strtoupper($this->getSequenceName($seq_name));
|
||||
$repeat = 0;
|
||||
@ -742,7 +749,7 @@ class DB_ibase extends DB_common
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_ibase::nextID(), DB_ibase::dropSequence()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
$sqn = strtoupper($this->getSequenceName($seq_name));
|
||||
$this->pushErrorHandling(PEAR_ERROR_RETURN);
|
||||
@ -765,7 +772,7 @@ class DB_ibase extends DB_common
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_ibase::nextID(), DB_ibase::createSequence()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->query('DELETE FROM RDB$GENERATORS '
|
||||
. "WHERE RDB\$GENERATOR_NAME='"
|
||||
@ -789,7 +796,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _ibaseFieldFlags($field_name, $table_name)
|
||||
public function _ibaseFieldFlags($field_name, $table_name)
|
||||
{
|
||||
$sql = 'SELECT R.RDB$CONSTRAINT_TYPE CTYPE'
|
||||
.' FROM RDB$INDEX_SEGMENTS I'
|
||||
@ -860,7 +867,7 @@ class DB_ibase extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_ibase::errorNative(), DB_ibase::errorCode()
|
||||
*/
|
||||
function &ibaseRaiseError($errno = null)
|
||||
public function &ibaseRaiseError($errno = null)
|
||||
{
|
||||
if ($errno === null) {
|
||||
$errno = $this->errorCode($this->errorNative());
|
||||
@ -879,13 +886,16 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @since Method available since Release 1.7.0
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
if (function_exists('ibase_errcode')) {
|
||||
return @ibase_errcode();
|
||||
}
|
||||
if (preg_match('/^Dynamic SQL Error SQL error code = ([0-9-]+)/i',
|
||||
@ibase_errmsg(), $m)) {
|
||||
if (preg_match(
|
||||
'/^Dynamic SQL Error SQL error code = ([0-9-]+)/i',
|
||||
@ibase_errmsg(),
|
||||
$m
|
||||
)) {
|
||||
return (int)$m[1];
|
||||
}
|
||||
return null;
|
||||
@ -905,7 +915,7 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @since Method available since Release 1.7.0
|
||||
*/
|
||||
function errorCode($nativecode = null)
|
||||
public function errorCode($nativecode = null)
|
||||
{
|
||||
if (isset($this->errorcode_map[$nativecode])) {
|
||||
return $this->errorcode_map[$nativecode];
|
||||
@ -969,15 +979,17 @@ class DB_ibase extends DB_common
|
||||
*
|
||||
* @see DB_common::tableInfo()
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
/*
|
||||
* Probably received a table name.
|
||||
* Create a result resource identifier.
|
||||
*/
|
||||
$id = @ibase_query($this->connection,
|
||||
"SELECT * FROM $result WHERE 1=0");
|
||||
$id = @ibase_query(
|
||||
$this->connection,
|
||||
"SELECT * FROM $result WHERE 1=0"
|
||||
);
|
||||
$got_string = true;
|
||||
} elseif (isset($result->result)) {
|
||||
/*
|
||||
@ -1053,7 +1065,7 @@ class DB_ibase extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'tables':
|
||||
@ -1069,7 +1081,6 @@ class DB_ibase extends DB_common
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1078,5 +1089,3 @@ class DB_ibase extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -59,13 +59,13 @@ class DB_ifx extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'ifx';
|
||||
public $phptype = 'ifx';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'ifx';
|
||||
public $dbsyntax = 'ifx';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -80,7 +80,7 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => 'emulate',
|
||||
'new_link' => false,
|
||||
'numrows' => 'emulate',
|
||||
@ -94,7 +94,7 @@ class DB_ifx extends DB_common
|
||||
* A mapping of native error codes to DB error codes
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
'-201' => DB_ERROR_SYNTAX,
|
||||
'-206' => DB_ERROR_NOSUCHTABLE,
|
||||
'-217' => DB_ERROR_NOSUCHFIELD,
|
||||
@ -128,13 +128,13 @@ class DB_ifx extends DB_common
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -142,7 +142,7 @@ class DB_ifx extends DB_common
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $autocommit = true;
|
||||
public $autocommit = true;
|
||||
|
||||
/**
|
||||
* The quantity of transactions begun
|
||||
@ -153,14 +153,14 @@ class DB_ifx extends DB_common
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $transaction_opcount = 0;
|
||||
public $transaction_opcount = 0;
|
||||
|
||||
/**
|
||||
* The number of rows affected by a data manipulation query
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $affected = 0;
|
||||
public $affected = 0;
|
||||
|
||||
|
||||
// }}}
|
||||
@ -171,7 +171,7 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -189,11 +189,10 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('informix') &&
|
||||
!PEAR::loadExtension('Informix'))
|
||||
{
|
||||
!PEAR::loadExtension('Informix')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
}
|
||||
|
||||
@ -224,7 +223,7 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$ret = @ifx_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -243,7 +242,7 @@ class DB_ifx extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$ismanip = $this->_checkManip($query);
|
||||
$this->last_query = $query;
|
||||
@ -294,7 +293,7 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @return true if a result is available otherwise return false
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -309,7 +308,7 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
if ($this->_last_query_manip) {
|
||||
return $this->affected;
|
||||
@ -341,7 +340,7 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
if (($rownum !== null) && ($rownum < 0)) {
|
||||
return null;
|
||||
@ -367,8 +366,7 @@ class DB_ifx extends DB_common
|
||||
}
|
||||
$arr = $order;
|
||||
} elseif ($fetchmode == DB_FETCHMODE_ASSOC &&
|
||||
$this->options['portability'] & DB_PORTABILITY_LOWERCASE)
|
||||
{
|
||||
$this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
|
||||
$arr = array_change_key_case($arr, CASE_LOWER);
|
||||
}
|
||||
if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
|
||||
@ -396,7 +394,7 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
if (!$cols = @ifx_num_fields($result)) {
|
||||
return $this->ifxRaiseError();
|
||||
@ -420,7 +418,7 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
return is_resource($result) ? ifx_free_result($result) : false;
|
||||
}
|
||||
@ -436,7 +434,7 @@ class DB_ifx extends DB_common
|
||||
* @return int DB_OK on success. A DB_Error object if the driver
|
||||
* doesn't support auto-committing transactions.
|
||||
*/
|
||||
function autoCommit($onoff = true)
|
||||
public function autoCommit($onoff = true)
|
||||
{
|
||||
// XXX if $this->transaction_opcount > 0, we should probably
|
||||
// issue a warning here.
|
||||
@ -452,7 +450,7 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function commit()
|
||||
public function commit()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
$result = @ifx_query('COMMIT WORK', $this->connection);
|
||||
@ -472,7 +470,7 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function rollback()
|
||||
public function rollback()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
$result = @ifx_query('ROLLBACK WORK', $this->connection);
|
||||
@ -499,13 +497,18 @@ class DB_ifx extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_ifx::errorNative(), DB_ifx::errorCode()
|
||||
*/
|
||||
function ifxRaiseError($errno = null)
|
||||
public function ifxRaiseError($errno = null)
|
||||
{
|
||||
if ($errno === null) {
|
||||
$errno = $this->errorCode(ifx_error());
|
||||
}
|
||||
return $this->raiseError($errno, null, null, null,
|
||||
$this->errorNative());
|
||||
return $this->raiseError(
|
||||
$errno,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$this->errorNative()
|
||||
);
|
||||
}
|
||||
|
||||
// }}}
|
||||
@ -516,7 +519,7 @@ class DB_ifx extends DB_common
|
||||
*
|
||||
* @return string the DBMS' error code and message
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
return @ifx_error() . ' ' . @ifx_errormsg();
|
||||
}
|
||||
@ -534,7 +537,7 @@ class DB_ifx extends DB_common
|
||||
* @return int a portable DB error code, or DB_ERROR if this DB
|
||||
* implementation has no mapping for the given error code.
|
||||
*/
|
||||
function errorCode($nativecode)
|
||||
public function errorCode($nativecode)
|
||||
{
|
||||
if (preg_match('/SQLCODE=(.*)]/', $nativecode, $match)) {
|
||||
$code = $match[1];
|
||||
@ -570,15 +573,17 @@ class DB_ifx extends DB_common
|
||||
* @see DB_common::tableInfo()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
/*
|
||||
* Probably received a table name.
|
||||
* Create a result resource identifier.
|
||||
*/
|
||||
$id = @ifx_query("SELECT * FROM $result WHERE 1=0",
|
||||
$this->connection);
|
||||
$id = @ifx_query(
|
||||
"SELECT * FROM $result WHERE 1=0",
|
||||
$this->connection
|
||||
);
|
||||
$got_string = true;
|
||||
} elseif (isset($result->result)) {
|
||||
/*
|
||||
@ -659,7 +664,7 @@ class DB_ifx extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'tables':
|
||||
@ -670,7 +675,6 @@ class DB_ifx extends DB_common
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -679,5 +683,3 @@ class DB_ifx extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -59,13 +59,13 @@ class DB_msql extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'msql';
|
||||
public $phptype = 'msql';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'msql';
|
||||
public $dbsyntax = 'msql';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -80,7 +80,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => 'emulate',
|
||||
'new_link' => false,
|
||||
'numrows' => true,
|
||||
@ -94,20 +94,20 @@ class DB_msql extends DB_common
|
||||
* A mapping of native error codes to DB error codes
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
);
|
||||
|
||||
/**
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -119,7 +119,7 @@ class DB_msql extends DB_common
|
||||
* @var resource
|
||||
* @access private
|
||||
*/
|
||||
var $_result;
|
||||
public $_result;
|
||||
|
||||
|
||||
// }}}
|
||||
@ -130,7 +130,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -164,7 +164,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('msql')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
@ -187,24 +187,36 @@ class DB_msql extends DB_common
|
||||
$ini = ini_get('track_errors');
|
||||
$php_errormsg = '';
|
||||
if ($ini) {
|
||||
$this->connection = @call_user_func_array($connect_function,
|
||||
$params);
|
||||
$this->connection = @call_user_func_array(
|
||||
$connect_function,
|
||||
$params
|
||||
);
|
||||
} else {
|
||||
@ini_set('track_errors', 1);
|
||||
$this->connection = @call_user_func_array($connect_function,
|
||||
$params);
|
||||
$this->connection = @call_user_func_array(
|
||||
$connect_function,
|
||||
$params
|
||||
);
|
||||
@ini_set('track_errors', $ini);
|
||||
}
|
||||
|
||||
if (!$this->connection) {
|
||||
if (($err = @msql_error()) != '') {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$err);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$err
|
||||
);
|
||||
} else {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$php_errormsg);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$php_errormsg
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,7 +234,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$ret = @msql_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -241,7 +253,7 @@ class DB_msql extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$this->last_query = $query;
|
||||
$query = $this->modifyQuery($query);
|
||||
@ -273,7 +285,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @return true if a result is available otherwise return false
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -305,7 +317,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
if ($rownum !== null) {
|
||||
if (!@msql_data_seek($result, $rownum)) {
|
||||
@ -348,7 +360,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
return is_resource($result) ? msql_free_result($result) : false;
|
||||
}
|
||||
@ -369,7 +381,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
$cols = @msql_num_fields($result);
|
||||
if (!$cols) {
|
||||
@ -394,7 +406,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @see DB_result::numRows()
|
||||
*/
|
||||
function numRows($result)
|
||||
public function numRows($result)
|
||||
{
|
||||
$rows = @msql_num_rows($result);
|
||||
if ($rows === false) {
|
||||
@ -413,7 +425,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
if (!$this->_result) {
|
||||
return 0;
|
||||
@ -437,7 +449,7 @@ class DB_msql extends DB_common
|
||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||
* DB_msql::createSequence(), DB_msql::dropSequence()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
$repeat = false;
|
||||
@ -482,7 +494,7 @@ class DB_msql extends DB_common
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_msql::nextID(), DB_msql::dropSequence()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
$res = $this->query('CREATE TABLE ' . $seqname
|
||||
@ -507,7 +519,7 @@ class DB_msql extends DB_common
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_msql::nextID(), DB_msql::createSequence()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
|
||||
}
|
||||
@ -525,7 +537,7 @@ class DB_msql extends DB_common
|
||||
* @see DB_common::quoteIdentifier()
|
||||
* @since Method available since Release 1.7.0
|
||||
*/
|
||||
function quoteIdentifier($str)
|
||||
public function quoteIdentifier($str)
|
||||
{
|
||||
return $this->raiseError(DB_ERROR_UNSUPPORTED);
|
||||
}
|
||||
@ -542,7 +554,8 @@ class DB_msql extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since release 1.7.8.
|
||||
*/
|
||||
function quoteFloat($float) {
|
||||
public function quoteFloat($float)
|
||||
{
|
||||
return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
|
||||
}
|
||||
|
||||
@ -559,7 +572,7 @@ class DB_msql extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since Release 1.7.0
|
||||
*/
|
||||
function escapeSimple($str)
|
||||
public function escapeSimple($str)
|
||||
{
|
||||
return addslashes($str);
|
||||
}
|
||||
@ -579,7 +592,7 @@ class DB_msql extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_msql::errorNative(), DB_msql::errorCode()
|
||||
*/
|
||||
function msqlRaiseError($errno = null)
|
||||
public function msqlRaiseError($errno = null)
|
||||
{
|
||||
$native = $this->errorNative();
|
||||
if ($errno === null) {
|
||||
@ -596,7 +609,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @return string the DBMS' error message
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
return @msql_error();
|
||||
}
|
||||
@ -611,7 +624,7 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @return integer the error number from a DB_ERROR* constant
|
||||
*/
|
||||
function errorCode($errormsg)
|
||||
public function errorCode($errormsg)
|
||||
{
|
||||
static $error_regexps;
|
||||
|
||||
@ -702,15 +715,17 @@ class DB_msql extends DB_common
|
||||
*
|
||||
* @see DB_common::setOption()
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
/*
|
||||
* Probably received a table name.
|
||||
* Create a result resource identifier.
|
||||
*/
|
||||
$id = @msql_query("SELECT * FROM $result",
|
||||
$this->connection);
|
||||
$id = @msql_query(
|
||||
"SELECT * FROM $result",
|
||||
$this->connection
|
||||
);
|
||||
$got_string = true;
|
||||
} elseif (isset($result->result)) {
|
||||
/*
|
||||
@ -794,15 +809,17 @@ class DB_msql extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'databases':
|
||||
$id = @msql_list_dbs($this->connection);
|
||||
break;
|
||||
case 'tables':
|
||||
$id = @msql_list_tables($this->dsn['database'],
|
||||
$this->connection);
|
||||
$id = @msql_list_tables(
|
||||
$this->dsn['database'],
|
||||
$this->connection
|
||||
);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
@ -818,7 +835,6 @@ class DB_msql extends DB_common
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -827,5 +843,3 @@ class DB_msql extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -60,13 +60,13 @@ class DB_mssql extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'mssql';
|
||||
public $phptype = 'mssql';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'mssql';
|
||||
public $dbsyntax = 'mssql';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -81,7 +81,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => 'emulate',
|
||||
'new_link' => false,
|
||||
'numrows' => true,
|
||||
@ -96,7 +96,7 @@ class DB_mssql extends DB_common
|
||||
* @var array
|
||||
*/
|
||||
// XXX Add here error codes ie: 'S100E' => DB_ERROR_SYNTAX
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
102 => DB_ERROR_SYNTAX,
|
||||
110 => DB_ERROR_VALUE_COUNT_ON_ROW,
|
||||
155 => DB_ERROR_NOSUCHFIELD,
|
||||
@ -137,13 +137,13 @@ class DB_mssql extends DB_common
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -151,7 +151,7 @@ class DB_mssql extends DB_common
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $autocommit = true;
|
||||
public $autocommit = true;
|
||||
|
||||
/**
|
||||
* The quantity of transactions begun
|
||||
@ -162,7 +162,7 @@ class DB_mssql extends DB_common
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $transaction_opcount = 0;
|
||||
public $transaction_opcount = 0;
|
||||
|
||||
/**
|
||||
* The database specified in the DSN
|
||||
@ -172,7 +172,7 @@ class DB_mssql extends DB_common
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_db = null;
|
||||
public $_db = null;
|
||||
|
||||
|
||||
// }}}
|
||||
@ -183,7 +183,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -201,11 +201,10 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('mssql') && !PEAR::loadExtension('sybase')
|
||||
&& !PEAR::loadExtension('sybase_ct'))
|
||||
{
|
||||
&& !PEAR::loadExtension('sybase_ct')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
}
|
||||
|
||||
@ -229,15 +228,23 @@ class DB_mssql extends DB_common
|
||||
$this->connection = @call_user_func_array($connect_function, $params);
|
||||
|
||||
if (!$this->connection) {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
@mssql_get_last_message());
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@mssql_get_last_message()
|
||||
);
|
||||
}
|
||||
if ($dsn['database']) {
|
||||
if (!@mssql_select_db($dsn['database'], $this->connection)) {
|
||||
return $this->raiseError(DB_ERROR_NODBSELECTED,
|
||||
null, null, null,
|
||||
@mssql_get_last_message());
|
||||
return $this->raiseError(
|
||||
DB_ERROR_NODBSELECTED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@mssql_get_last_message()
|
||||
);
|
||||
}
|
||||
$this->_db = $dsn['database'];
|
||||
}
|
||||
@ -252,7 +259,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$ret = @mssql_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -271,7 +278,7 @@ class DB_mssql extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$ismanip = $this->_checkManip($query);
|
||||
$this->last_query = $query;
|
||||
@ -309,7 +316,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @return true if a result is available otherwise return false
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return @mssql_next_result($result);
|
||||
}
|
||||
@ -337,7 +344,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
if ($rownum !== null) {
|
||||
if (!@mssql_data_seek($result, $rownum)) {
|
||||
@ -380,7 +387,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
return is_resource($result) ? mssql_free_result($result) : false;
|
||||
}
|
||||
@ -401,7 +408,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
$cols = @mssql_num_fields($result);
|
||||
if (!$cols) {
|
||||
@ -426,7 +433,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @see DB_result::numRows()
|
||||
*/
|
||||
function numRows($result)
|
||||
public function numRows($result)
|
||||
{
|
||||
$rows = @mssql_num_rows($result);
|
||||
if ($rows === false) {
|
||||
@ -446,7 +453,7 @@ class DB_mssql extends DB_common
|
||||
* @return int DB_OK on success. A DB_Error object if the driver
|
||||
* doesn't support auto-committing transactions.
|
||||
*/
|
||||
function autoCommit($onoff = false)
|
||||
public function autoCommit($onoff = false)
|
||||
{
|
||||
// XXX if $this->transaction_opcount > 0, we should probably
|
||||
// issue a warning here.
|
||||
@ -462,7 +469,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function commit()
|
||||
public function commit()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
if (!@mssql_select_db($this->_db, $this->connection)) {
|
||||
@ -485,7 +492,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function rollback()
|
||||
public function rollback()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
if (!@mssql_select_db($this->_db, $this->connection)) {
|
||||
@ -510,7 +517,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
if ($this->_last_query_manip) {
|
||||
$res = @mssql_query('select @@rowcount', $this->connection);
|
||||
@ -546,7 +553,7 @@ class DB_mssql extends DB_common
|
||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||
* DB_mssql::createSequence(), DB_mssql::dropSequence()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
if (!@mssql_select_db($this->_db, $this->connection)) {
|
||||
@ -558,8 +565,7 @@ class DB_mssql extends DB_common
|
||||
$result = $this->query("INSERT INTO $seqname (vapor) VALUES (0)");
|
||||
$this->popErrorHandling();
|
||||
if ($ondemand && DB::isError($result) &&
|
||||
($result->getCode() == DB_ERROR || $result->getCode() == DB_ERROR_NOSUCHTABLE))
|
||||
{
|
||||
($result->getCode() == DB_ERROR || $result->getCode() == DB_ERROR_NOSUCHTABLE)) {
|
||||
$repeat = 1;
|
||||
$result = $this->createSequence($seq_name);
|
||||
if (DB::isError($result)) {
|
||||
@ -597,7 +603,7 @@ class DB_mssql extends DB_common
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_mssql::nextID(), DB_mssql::dropSequence()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
return $this->query('CREATE TABLE '
|
||||
. $this->getSequenceName($seq_name)
|
||||
@ -618,7 +624,7 @@ class DB_mssql extends DB_common
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_mssql::nextID(), DB_mssql::createSequence()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
|
||||
}
|
||||
@ -635,7 +641,7 @@ class DB_mssql extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function escapeSimple($str)
|
||||
public function escapeSimple($str)
|
||||
{
|
||||
return str_replace(
|
||||
array("'", "\\\r\n", "\\\n"),
|
||||
@ -657,7 +663,7 @@ class DB_mssql extends DB_common
|
||||
* @see DB_common::quoteIdentifier()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function quoteIdentifier($str)
|
||||
public function quoteIdentifier($str)
|
||||
{
|
||||
return '[' . str_replace(']', ']]', $str) . ']';
|
||||
}
|
||||
@ -677,14 +683,19 @@ class DB_mssql extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_mssql::errorNative(), DB_mssql::errorCode()
|
||||
*/
|
||||
function mssqlRaiseError($code = null)
|
||||
public function mssqlRaiseError($code = null)
|
||||
{
|
||||
$message = @mssql_get_last_message();
|
||||
if (!$code) {
|
||||
$code = $this->errorNative();
|
||||
}
|
||||
return $this->raiseError($this->errorCode($code, $message),
|
||||
null, null, null, "$code - $message");
|
||||
return $this->raiseError(
|
||||
$this->errorCode($code, $message),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"$code - $message"
|
||||
);
|
||||
}
|
||||
|
||||
// }}}
|
||||
@ -695,7 +706,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @return int the DBMS' error code
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
$res = @mssql_query('select @@ERROR as ErrorCode', $this->connection);
|
||||
if (!$res) {
|
||||
@ -717,15 +728,14 @@ class DB_mssql extends DB_common
|
||||
* @return integer an error number from a DB error constant
|
||||
* @see errorNative()
|
||||
*/
|
||||
function errorCode($nativecode = null, $msg = '')
|
||||
public function errorCode($nativecode = null, $msg = '')
|
||||
{
|
||||
if (!$nativecode) {
|
||||
$nativecode = $this->errorNative();
|
||||
}
|
||||
if (isset($this->errorcode_map[$nativecode])) {
|
||||
if ($nativecode == 3701
|
||||
&& preg_match('/Cannot drop the index/i', $msg))
|
||||
{
|
||||
&& preg_match('/Cannot drop the index/i', $msg)) {
|
||||
return DB_ERROR_NOT_FOUND;
|
||||
}
|
||||
return $this->errorcode_map[$nativecode];
|
||||
@ -755,7 +765,7 @@ class DB_mssql extends DB_common
|
||||
*
|
||||
* @see DB_common::tableInfo()
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
/*
|
||||
@ -765,8 +775,10 @@ class DB_mssql extends DB_common
|
||||
if (!@mssql_select_db($this->_db, $this->connection)) {
|
||||
return $this->mssqlRaiseError(DB_ERROR_NODBSELECTED);
|
||||
}
|
||||
$id = @mssql_query("SELECT * FROM $result WHERE 1=0",
|
||||
$this->connection);
|
||||
$id = @mssql_query(
|
||||
"SELECT * FROM $result WHERE 1=0",
|
||||
$this->connection
|
||||
);
|
||||
$got_string = true;
|
||||
} elseif (isset($result->result)) {
|
||||
/*
|
||||
@ -804,8 +816,10 @@ class DB_mssql extends DB_common
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($got_string) {
|
||||
$flags = $this->_mssql_field_flags($result,
|
||||
@mssql_field_name($id, $i));
|
||||
$flags = $this->_mssql_field_flags(
|
||||
$result,
|
||||
@mssql_field_name($id, $i)
|
||||
);
|
||||
if (DB::isError($flags)) {
|
||||
return $flags;
|
||||
}
|
||||
@ -858,13 +872,12 @@ class DB_mssql extends DB_common
|
||||
* @access private
|
||||
* @author Joern Barthel <j_barthel@web.de>
|
||||
*/
|
||||
function _mssql_field_flags($table, $column)
|
||||
public function _mssql_field_flags($table, $column)
|
||||
{
|
||||
static $tableName = null;
|
||||
static $flags = array();
|
||||
|
||||
if ($table != $tableName) {
|
||||
|
||||
$flags = array();
|
||||
$tableName = $table;
|
||||
|
||||
@ -935,7 +948,7 @@ class DB_mssql extends DB_common
|
||||
* @access private
|
||||
* @author Joern Barthel <j_barthel@web.de>
|
||||
*/
|
||||
function _add_flag(&$array, $value)
|
||||
public function _add_flag(&$array, $value)
|
||||
{
|
||||
if (!is_array($array)) {
|
||||
$array = array($value);
|
||||
@ -958,7 +971,7 @@ class DB_mssql extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'tables':
|
||||
@ -980,5 +993,3 @@ class DB_mssql extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -52,13 +52,13 @@ class DB_mysql extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'mysql';
|
||||
public $phptype = 'mysql';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'mysql';
|
||||
public $dbsyntax = 'mysql';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -73,7 +73,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => 'alter',
|
||||
'new_link' => '4.2.0',
|
||||
'numrows' => true,
|
||||
@ -87,7 +87,7 @@ class DB_mysql extends DB_common
|
||||
* A mapping of native error codes to DB error codes
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
1004 => DB_ERROR_CANNOT_CREATE,
|
||||
1005 => DB_ERROR_CANNOT_CREATE,
|
||||
1006 => DB_ERROR_CANNOT_CREATE,
|
||||
@ -120,13 +120,13 @@ class DB_mysql extends DB_common
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -134,7 +134,7 @@ class DB_mysql extends DB_common
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $autocommit = true;
|
||||
public $autocommit = true;
|
||||
|
||||
/**
|
||||
* The quantity of transactions begun
|
||||
@ -145,7 +145,7 @@ class DB_mysql extends DB_common
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $transaction_opcount = 0;
|
||||
public $transaction_opcount = 0;
|
||||
|
||||
/**
|
||||
* The database specified in the DSN
|
||||
@ -155,7 +155,7 @@ class DB_mysql extends DB_common
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_db = '';
|
||||
public $_db = '';
|
||||
|
||||
|
||||
// }}}
|
||||
@ -166,7 +166,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -193,7 +193,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('mysql')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
@ -219,8 +219,7 @@ class DB_mysql extends DB_common
|
||||
|
||||
if (!$persistent) {
|
||||
if (isset($dsn['new_link'])
|
||||
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true))
|
||||
{
|
||||
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true)) {
|
||||
$params[] = true;
|
||||
} else {
|
||||
$params[] = false;
|
||||
@ -236,24 +235,36 @@ class DB_mysql extends DB_common
|
||||
$ini = ini_get('track_errors');
|
||||
$php_errormsg = '';
|
||||
if ($ini) {
|
||||
$this->connection = @call_user_func_array($connect_function,
|
||||
$params);
|
||||
$this->connection = @call_user_func_array(
|
||||
$connect_function,
|
||||
$params
|
||||
);
|
||||
} else {
|
||||
@ini_set('track_errors', 1);
|
||||
$this->connection = @call_user_func_array($connect_function,
|
||||
$params);
|
||||
$this->connection = @call_user_func_array(
|
||||
$connect_function,
|
||||
$params
|
||||
);
|
||||
@ini_set('track_errors', $ini);
|
||||
}
|
||||
|
||||
if (!$this->connection) {
|
||||
if (($err = @mysql_error()) != '') {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$err);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$err
|
||||
);
|
||||
} else {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$php_errormsg);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$php_errormsg
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,7 +286,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$ret = @mysql_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -298,7 +309,7 @@ class DB_mysql extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$ismanip = $this->_checkManip($query);
|
||||
$this->last_query = $query;
|
||||
@ -344,7 +355,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -372,7 +383,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
if ($rownum !== null) {
|
||||
if (!@mysql_data_seek($result, $rownum)) {
|
||||
@ -420,7 +431,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
return is_resource($result) ? mysql_free_result($result) : false;
|
||||
}
|
||||
@ -441,7 +452,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
$cols = @mysql_num_fields($result);
|
||||
if (!$cols) {
|
||||
@ -466,7 +477,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @see DB_result::numRows()
|
||||
*/
|
||||
function numRows($result)
|
||||
public function numRows($result)
|
||||
{
|
||||
$rows = @mysql_num_rows($result);
|
||||
if ($rows === null) {
|
||||
@ -486,7 +497,7 @@ class DB_mysql extends DB_common
|
||||
* @return int DB_OK on success. A DB_Error object if the driver
|
||||
* doesn't support auto-committing transactions.
|
||||
*/
|
||||
function autoCommit($onoff = false)
|
||||
public function autoCommit($onoff = false)
|
||||
{
|
||||
// XXX if $this->transaction_opcount > 0, we should probably
|
||||
// issue a warning here.
|
||||
@ -502,7 +513,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function commit()
|
||||
public function commit()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
if ($this->_db) {
|
||||
@ -528,7 +539,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function rollback()
|
||||
public function rollback()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
if ($this->_db) {
|
||||
@ -556,7 +567,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
if ($this->_last_query_manip) {
|
||||
return @mysql_affected_rows($this->connection);
|
||||
@ -581,7 +592,7 @@ class DB_mysql extends DB_common
|
||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||
* DB_mysql::createSequence(), DB_mysql::dropSequence()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
do {
|
||||
@ -622,10 +633,8 @@ class DB_mysql extends DB_common
|
||||
}
|
||||
// We know what the result will be, so no need to try again
|
||||
return 1;
|
||||
|
||||
} elseif ($ondemand && DB::isError($result) &&
|
||||
$result->getCode() == DB_ERROR_NOSUCHTABLE)
|
||||
{
|
||||
$result->getCode() == DB_ERROR_NOSUCHTABLE) {
|
||||
// ONDEMAND TABLE CREATION
|
||||
$result = $this->createSequence($seq_name);
|
||||
if (DB::isError($result)) {
|
||||
@ -633,10 +642,8 @@ class DB_mysql extends DB_common
|
||||
} else {
|
||||
$repeat = 1;
|
||||
}
|
||||
|
||||
} elseif (DB::isError($result) &&
|
||||
$result->getCode() == DB_ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
$result->getCode() == DB_ERROR_ALREADY_EXISTS) {
|
||||
// BACKWARDS COMPAT
|
||||
// see _BCsequence() comment
|
||||
$result = $this->_BCsequence($seqname);
|
||||
@ -663,7 +670,7 @@ class DB_mysql extends DB_common
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_mysql::nextID(), DB_mysql::dropSequence()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
$res = $this->query('CREATE TABLE ' . $seqname
|
||||
@ -694,7 +701,7 @@ class DB_mysql extends DB_common
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_mysql::nextID(), DB_mysql::createSequence()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
|
||||
}
|
||||
@ -712,7 +719,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _BCsequence($seqname)
|
||||
public function _BCsequence($seqname)
|
||||
{
|
||||
// Obtain a user-level lock... this will release any previous
|
||||
// application locks, but unlike LOCK TABLES, it does not abort
|
||||
@ -767,7 +774,7 @@ class DB_mysql extends DB_common
|
||||
* @see DB_common::quoteIdentifier()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function quoteIdentifier($str)
|
||||
public function quoteIdentifier($str)
|
||||
{
|
||||
return '`' . str_replace('`', '``', $str) . '`';
|
||||
}
|
||||
@ -785,7 +792,7 @@ class DB_mysql extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function escapeSimple($str)
|
||||
public function escapeSimple($str)
|
||||
{
|
||||
if (function_exists('mysql_real_escape_string')) {
|
||||
return @mysql_real_escape_string($str, $this->connection);
|
||||
@ -811,14 +818,17 @@ class DB_mysql extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::setOption()
|
||||
*/
|
||||
function modifyQuery($query)
|
||||
public function modifyQuery($query)
|
||||
{
|
||||
if ($this->options['portability'] & DB_PORTABILITY_DELETE_COUNT) {
|
||||
// "DELETE FROM table" gives 0 affected rows in MySQL.
|
||||
// This little hack lets you know how many rows were deleted.
|
||||
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) {
|
||||
$query = preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/',
|
||||
'DELETE FROM \1 WHERE 1=1', $query);
|
||||
$query = preg_replace(
|
||||
'/^\s*DELETE\s+FROM\s+(\S+)\s*$/',
|
||||
'DELETE FROM \1 WHERE 1=1',
|
||||
$query
|
||||
);
|
||||
}
|
||||
}
|
||||
return $query;
|
||||
@ -843,7 +853,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
{
|
||||
if (DB::isManip($query) || $this->_next_query_manip) {
|
||||
return $query . " LIMIT $count";
|
||||
@ -867,7 +877,7 @@ class DB_mysql extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_mysql::errorNative(), DB_common::errorCode()
|
||||
*/
|
||||
function mysqlRaiseError($errno = null)
|
||||
public function mysqlRaiseError($errno = null)
|
||||
{
|
||||
if ($errno === null) {
|
||||
if ($this->options['portability'] & DB_PORTABILITY_ERRORS) {
|
||||
@ -882,9 +892,14 @@ class DB_mysql extends DB_common
|
||||
}
|
||||
$errno = $this->errorCode(mysql_errno($this->connection));
|
||||
}
|
||||
return $this->raiseError($errno, null, null, null,
|
||||
return $this->raiseError(
|
||||
$errno,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@mysql_errno($this->connection) . ' ** ' .
|
||||
@mysql_error($this->connection));
|
||||
@mysql_error($this->connection)
|
||||
);
|
||||
}
|
||||
|
||||
// }}}
|
||||
@ -895,7 +910,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @return int the DBMS' error code
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
return @mysql_errno($this->connection);
|
||||
}
|
||||
@ -918,7 +933,7 @@ class DB_mysql extends DB_common
|
||||
*
|
||||
* @see DB_common::tableInfo()
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
// Fix for bug #11580.
|
||||
@ -932,8 +947,10 @@ class DB_mysql extends DB_common
|
||||
* Probably received a table name.
|
||||
* Create a result resource identifier.
|
||||
*/
|
||||
$id = @mysql_query("SELECT * FROM $result LIMIT 0",
|
||||
$this->connection);
|
||||
$id = @mysql_query(
|
||||
"SELECT * FROM $result LIMIT 0",
|
||||
$this->connection
|
||||
);
|
||||
$got_string = true;
|
||||
} elseif (isset($result->result)) {
|
||||
/*
|
||||
@ -1006,7 +1023,7 @@ class DB_mysql extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'tables':
|
||||
@ -1021,7 +1038,6 @@ class DB_mysql extends DB_common
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1030,5 +1046,3 @@ class DB_mysql extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -55,13 +55,13 @@ class DB_mysqli extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'mysqli';
|
||||
public $phptype = 'mysqli';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'mysqli';
|
||||
public $dbsyntax = 'mysqli';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -76,7 +76,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => 'alter',
|
||||
'new_link' => false,
|
||||
'numrows' => true,
|
||||
@ -90,7 +90,7 @@ class DB_mysqli extends DB_common
|
||||
* A mapping of native error codes to DB error codes
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
1004 => DB_ERROR_CANNOT_CREATE,
|
||||
1005 => DB_ERROR_CANNOT_CREATE,
|
||||
1006 => DB_ERROR_CANNOT_CREATE,
|
||||
@ -123,13 +123,13 @@ class DB_mysqli extends DB_common
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -137,7 +137,7 @@ class DB_mysqli extends DB_common
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $autocommit = true;
|
||||
public $autocommit = true;
|
||||
|
||||
/**
|
||||
* The quantity of transactions begun
|
||||
@ -148,7 +148,7 @@ class DB_mysqli extends DB_common
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $transaction_opcount = 0;
|
||||
public $transaction_opcount = 0;
|
||||
|
||||
/**
|
||||
* The database specified in the DSN
|
||||
@ -158,7 +158,7 @@ class DB_mysqli extends DB_common
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_db = '';
|
||||
public $_db = '';
|
||||
|
||||
/**
|
||||
* Array for converting MYSQLI_*_FLAG constants to text values
|
||||
@ -166,7 +166,7 @@ class DB_mysqli extends DB_common
|
||||
* @access public
|
||||
* @since Property available since Release 1.6.5
|
||||
*/
|
||||
var $mysqli_flags = array(
|
||||
public $mysqli_flags = array(
|
||||
MYSQLI_NOT_NULL_FLAG => 'not_null',
|
||||
MYSQLI_PRI_KEY_FLAG => 'primary_key',
|
||||
MYSQLI_UNIQUE_KEY_FLAG => 'unique_key',
|
||||
@ -188,7 +188,7 @@ class DB_mysqli extends DB_common
|
||||
* @access public
|
||||
* @since Property available since Release 1.6.5
|
||||
*/
|
||||
var $mysqli_types = array(
|
||||
public $mysqli_types = array(
|
||||
MYSQLI_TYPE_DECIMAL => 'decimal',
|
||||
MYSQLI_TYPE_TINY => 'tinyint',
|
||||
MYSQLI_TYPE_SHORT => 'int',
|
||||
@ -228,7 +228,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -282,7 +282,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('mysqli')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
@ -314,8 +314,8 @@ class DB_mysqli extends DB_common
|
||||
$dsn['password'],
|
||||
$dsn['database'],
|
||||
$dsn['port'],
|
||||
$dsn['socket']))
|
||||
{
|
||||
$dsn['socket']
|
||||
)) {
|
||||
$this->connection = $init;
|
||||
}
|
||||
} else {
|
||||
@ -333,13 +333,21 @@ class DB_mysqli extends DB_common
|
||||
|
||||
if (!$this->connection) {
|
||||
if (($err = @mysqli_connect_error()) != '') {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$err);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$err
|
||||
);
|
||||
} else {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$php_errormsg);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$php_errormsg
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -358,7 +366,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$ret = @mysqli_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -377,7 +385,7 @@ class DB_mysqli extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$ismanip = $this->_checkManip($query);
|
||||
$this->last_query = $query;
|
||||
@ -419,7 +427,7 @@ class DB_mysqli extends DB_common
|
||||
* @return false
|
||||
* @access public
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -447,7 +455,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
if ($rownum !== null) {
|
||||
if (!@mysqli_data_seek($result, $rownum)) {
|
||||
@ -495,7 +503,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
if (! $result instanceof mysqli_result) {
|
||||
return false;
|
||||
@ -520,7 +528,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
$cols = @mysqli_num_fields($result);
|
||||
if (!$cols) {
|
||||
@ -545,7 +553,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @see DB_result::numRows()
|
||||
*/
|
||||
function numRows($result)
|
||||
public function numRows($result)
|
||||
{
|
||||
$rows = @mysqli_num_rows($result);
|
||||
if ($rows === null) {
|
||||
@ -565,7 +573,7 @@ class DB_mysqli extends DB_common
|
||||
* @return int DB_OK on success. A DB_Error object if the driver
|
||||
* doesn't support auto-committing transactions.
|
||||
*/
|
||||
function autoCommit($onoff = false)
|
||||
public function autoCommit($onoff = false)
|
||||
{
|
||||
// XXX if $this->transaction_opcount > 0, we should probably
|
||||
// issue a warning here.
|
||||
@ -581,7 +589,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function commit()
|
||||
public function commit()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
if ($this->_db) {
|
||||
@ -607,7 +615,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function rollback()
|
||||
public function rollback()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
if ($this->_db) {
|
||||
@ -635,7 +643,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
if ($this->_last_query_manip) {
|
||||
return @mysqli_affected_rows($this->connection);
|
||||
@ -660,7 +668,7 @@ class DB_mysqli extends DB_common
|
||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||
* DB_mysqli::createSequence(), DB_mysqli::dropSequence()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
do {
|
||||
@ -704,10 +712,8 @@ class DB_mysqli extends DB_common
|
||||
}
|
||||
// We know what the result will be, so no need to try again
|
||||
return 1;
|
||||
|
||||
} elseif ($ondemand && DB::isError($result) &&
|
||||
$result->getCode() == DB_ERROR_NOSUCHTABLE)
|
||||
{
|
||||
$result->getCode() == DB_ERROR_NOSUCHTABLE) {
|
||||
// ONDEMAND TABLE CREATION
|
||||
$result = $this->createSequence($seq_name);
|
||||
|
||||
@ -719,10 +725,8 @@ class DB_mysqli extends DB_common
|
||||
// First ID of a newly created sequence is 1
|
||||
return 1;
|
||||
}
|
||||
|
||||
} elseif (DB::isError($result) &&
|
||||
$result->getCode() == DB_ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
$result->getCode() == DB_ERROR_ALREADY_EXISTS) {
|
||||
// BACKWARDS COMPAT
|
||||
// see _BCsequence() comment
|
||||
$result = $this->_BCsequence($seqname);
|
||||
@ -746,7 +750,7 @@ class DB_mysqli extends DB_common
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_mysqli::nextID(), DB_mysqli::dropSequence()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
$res = $this->query('CREATE TABLE ' . $seqname
|
||||
@ -772,7 +776,7 @@ class DB_mysqli extends DB_common
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_mysql::nextID(), DB_mysql::createSequence()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
|
||||
}
|
||||
@ -790,7 +794,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _BCsequence($seqname)
|
||||
public function _BCsequence($seqname)
|
||||
{
|
||||
// Obtain a user-level lock... this will release any previous
|
||||
// application locks, but unlike LOCK TABLES, it does not abort
|
||||
@ -846,7 +850,7 @@ class DB_mysqli extends DB_common
|
||||
* @see DB_common::quoteIdentifier()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function quoteIdentifier($str)
|
||||
public function quoteIdentifier($str)
|
||||
{
|
||||
return '`' . str_replace('`', '``', $str) . '`';
|
||||
}
|
||||
@ -864,7 +868,7 @@ class DB_mysqli extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function escapeSimple($str)
|
||||
public function escapeSimple($str)
|
||||
{
|
||||
return @mysqli_real_escape_string($this->connection, $str);
|
||||
}
|
||||
@ -888,7 +892,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
{
|
||||
if (DB::isManip($query) || $this->_next_query_manip) {
|
||||
return $query . " LIMIT $count";
|
||||
@ -912,7 +916,7 @@ class DB_mysqli extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_mysqli::errorNative(), DB_common::errorCode()
|
||||
*/
|
||||
function mysqliRaiseError($errno = null)
|
||||
public function mysqliRaiseError($errno = null)
|
||||
{
|
||||
if ($errno === null) {
|
||||
if ($this->options['portability'] & DB_PORTABILITY_ERRORS) {
|
||||
@ -927,9 +931,14 @@ class DB_mysqli extends DB_common
|
||||
}
|
||||
$errno = $this->errorCode(mysqli_errno($this->connection));
|
||||
}
|
||||
return $this->raiseError($errno, null, null, null,
|
||||
return $this->raiseError(
|
||||
$errno,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@mysqli_errno($this->connection) . ' ** ' .
|
||||
@mysqli_error($this->connection));
|
||||
@mysqli_error($this->connection)
|
||||
);
|
||||
}
|
||||
|
||||
// }}}
|
||||
@ -940,7 +949,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @return int the DBMS' error code
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
return @mysqli_errno($this->connection);
|
||||
}
|
||||
@ -963,7 +972,7 @@ class DB_mysqli extends DB_common
|
||||
*
|
||||
* @see DB_common::setOption()
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
// Fix for bug #11580.
|
||||
@ -977,8 +986,10 @@ class DB_mysqli extends DB_common
|
||||
* Probably received a table name.
|
||||
* Create a result resource identifier.
|
||||
*/
|
||||
$id = @mysqli_query($this->connection,
|
||||
"SELECT * FROM $result LIMIT 0");
|
||||
$id = @mysqli_query(
|
||||
$this->connection,
|
||||
"SELECT * FROM $result LIMIT 0"
|
||||
);
|
||||
$got_string = true;
|
||||
} elseif (isset($result->result)) {
|
||||
/*
|
||||
@ -1072,7 +1083,7 @@ class DB_mysqli extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'tables':
|
||||
@ -1087,7 +1098,6 @@ class DB_mysqli extends DB_common
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1096,5 +1106,3 @@ class DB_mysqli extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -58,13 +58,13 @@ class DB_oci8 extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'oci8';
|
||||
public $phptype = 'oci8';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'oci8';
|
||||
public $dbsyntax = 'oci8';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -79,7 +79,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => 'alter',
|
||||
'new_link' => '5.0.0',
|
||||
'numrows' => 'subquery',
|
||||
@ -93,7 +93,7 @@ class DB_oci8 extends DB_common
|
||||
* A mapping of native error codes to DB error codes
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
1 => DB_ERROR_CONSTRAINT,
|
||||
900 => DB_ERROR_SYNTAX,
|
||||
904 => DB_ERROR_NOSUCHFIELD,
|
||||
@ -119,13 +119,13 @@ class DB_oci8 extends DB_common
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -133,7 +133,7 @@ class DB_oci8 extends DB_common
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $autocommit = true;
|
||||
public $autocommit = true;
|
||||
|
||||
/**
|
||||
* Stores the $data passed to execute() in the oci8 driver
|
||||
@ -146,27 +146,27 @@ class DB_oci8 extends DB_common
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_data = array();
|
||||
public $_data = array();
|
||||
|
||||
/**
|
||||
* The result or statement handle from the most recently executed query
|
||||
* @var resource
|
||||
*/
|
||||
var $last_stmt;
|
||||
public $last_stmt;
|
||||
|
||||
/**
|
||||
* Is the given prepared statement a data manipulation query?
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $manip_query = array();
|
||||
public $manip_query = array();
|
||||
|
||||
/**
|
||||
* Store of prepared SQL queries.
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_prepared_queries = array();
|
||||
public $_prepared_queries = array();
|
||||
|
||||
|
||||
// }}}
|
||||
@ -177,7 +177,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -213,7 +213,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('oci8')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
@ -233,8 +233,7 @@ class DB_oci8 extends DB_common
|
||||
|
||||
if (function_exists('oci_connect')) {
|
||||
if (isset($dsn['new_link'])
|
||||
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true))
|
||||
{
|
||||
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true)) {
|
||||
$connect_function = 'oci_new_connect';
|
||||
} else {
|
||||
$connect_function = $persistent ? 'oci_pconnect'
|
||||
@ -245,36 +244,48 @@ class DB_oci8 extends DB_common
|
||||
}
|
||||
|
||||
$char = empty($dsn['charset']) ? null : $dsn['charset'];
|
||||
$this->connection = @$connect_function($dsn['username'],
|
||||
$this->connection = @$connect_function(
|
||||
$dsn['username'],
|
||||
$dsn['password'],
|
||||
$db,
|
||||
$char);
|
||||
$char
|
||||
);
|
||||
$error = OCIError();
|
||||
if (!empty($error) && $error['code'] == 12541) {
|
||||
// Couldn't find TNS listener. Try direct connection.
|
||||
$this->connection = @$connect_function($dsn['username'],
|
||||
$this->connection = @$connect_function(
|
||||
$dsn['username'],
|
||||
$dsn['password'],
|
||||
null,
|
||||
$char);
|
||||
$char
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$connect_function = $persistent ? 'OCIPLogon' : 'OCILogon';
|
||||
if ($db) {
|
||||
$this->connection = @$connect_function($dsn['username'],
|
||||
$this->connection = @$connect_function(
|
||||
$dsn['username'],
|
||||
$dsn['password'],
|
||||
$db);
|
||||
$db
|
||||
);
|
||||
} elseif ($dsn['username'] || $dsn['password']) {
|
||||
$this->connection = @$connect_function($dsn['username'],
|
||||
$dsn['password']);
|
||||
$this->connection = @$connect_function(
|
||||
$dsn['username'],
|
||||
$dsn['password']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->connection) {
|
||||
$error = OCIError();
|
||||
$error = (is_array($error)) ? $error['message'] : null;
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$error);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$error
|
||||
);
|
||||
}
|
||||
return DB_OK;
|
||||
}
|
||||
@ -287,7 +298,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
if (function_exists('oci_close')) {
|
||||
$ret = @oci_close($this->connection);
|
||||
@ -314,7 +325,7 @@ class DB_oci8 extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$this->_data = array();
|
||||
$this->last_parameters = array();
|
||||
@ -325,9 +336,9 @@ class DB_oci8 extends DB_common
|
||||
return $this->oci8RaiseError();
|
||||
}
|
||||
if ($this->autocommit) {
|
||||
$success = @OCIExecute($result,OCI_COMMIT_ON_SUCCESS);
|
||||
$success = @OCIExecute($result, OCI_COMMIT_ON_SUCCESS);
|
||||
} else {
|
||||
$success = @OCIExecute($result,OCI_DEFAULT);
|
||||
$success = @OCIExecute($result, OCI_DEFAULT);
|
||||
}
|
||||
if (!$success) {
|
||||
return $this->oci8RaiseError($result);
|
||||
@ -353,7 +364,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @return true if a result is available otherwise return false
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -381,20 +392,19 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
if ($rownum !== null) {
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
if ($fetchmode & DB_FETCHMODE_ASSOC) {
|
||||
$moredata = @OCIFetchInto($result,$arr,OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS);
|
||||
$moredata = @OCIFetchInto($result, $arr, OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS);
|
||||
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE &&
|
||||
$moredata)
|
||||
{
|
||||
$moredata) {
|
||||
$arr = array_change_key_case($arr, CASE_LOWER);
|
||||
}
|
||||
} else {
|
||||
$moredata = OCIFetchInto($result,$arr,OCI_RETURN_NULLS+OCI_RETURN_LOBS);
|
||||
$moredata = OCIFetchInto($result, $arr, OCI_RETURN_NULLS+OCI_RETURN_LOBS);
|
||||
}
|
||||
if (!$moredata) {
|
||||
return null;
|
||||
@ -424,7 +434,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
return is_resource($result) ? OCIFreeStatement($result) : false;
|
||||
}
|
||||
@ -441,7 +451,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @see DB_oci8::prepare()
|
||||
*/
|
||||
function freePrepared($stmt, $free_resource = true)
|
||||
public function freePrepared($stmt, $free_resource = true)
|
||||
{
|
||||
if (!is_resource($stmt)) {
|
||||
return false;
|
||||
@ -478,12 +488,11 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @see DB_result::numRows(), DB_common::setOption()
|
||||
*/
|
||||
function numRows($result)
|
||||
public function numRows($result)
|
||||
{
|
||||
// emulate numRows for Oracle. yuck.
|
||||
if ($this->options['portability'] & DB_PORTABILITY_NUMROWS &&
|
||||
$result === $this->last_stmt)
|
||||
{
|
||||
$result === $this->last_stmt) {
|
||||
$countquery = 'SELECT COUNT(*) FROM ('.$this->last_query.')';
|
||||
$save_query = $this->last_query;
|
||||
$save_stmt = $this->last_stmt;
|
||||
@ -495,8 +504,7 @@ class DB_oci8 extends DB_common
|
||||
$this->last_stmt = $save_stmt;
|
||||
|
||||
if (DB::isError($count) ||
|
||||
DB::isError($row = $count->fetchRow(DB_FETCHMODE_ORDERED)))
|
||||
{
|
||||
DB::isError($row = $count->fetchRow(DB_FETCHMODE_ORDERED))) {
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
|
||||
@ -521,7 +529,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
$cols = @OCINumCols($result);
|
||||
if (!$cols) {
|
||||
@ -560,10 +568,14 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @see DB_oci8::execute()
|
||||
*/
|
||||
function prepare($query)
|
||||
public function prepare($query)
|
||||
{
|
||||
$tokens = preg_split('/((?<!\\\)[&?!])/', $query, -1,
|
||||
PREG_SPLIT_DELIM_CAPTURE);
|
||||
$tokens = preg_split(
|
||||
'/((?<!\\\)[&?!])/',
|
||||
$query,
|
||||
-1,
|
||||
PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
$binds = count($tokens) - 1;
|
||||
$token = 0;
|
||||
$types = array();
|
||||
@ -627,7 +639,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @see DB_oci8::prepare()
|
||||
*/
|
||||
function &execute($stmt, $data = array())
|
||||
public function &execute($stmt, $data = array())
|
||||
{
|
||||
$data = (array)$data;
|
||||
$this->last_parameters = $data;
|
||||
@ -671,8 +683,12 @@ class DB_oci8 extends DB_common
|
||||
$tmp = $this->oci8RaiseError($stmt);
|
||||
return $tmp;
|
||||
}
|
||||
$this->last_query = preg_replace("/:bind$i(?!\d)/",
|
||||
$this->quoteSmart($data[$key]), $this->last_query, 1);
|
||||
$this->last_query = preg_replace(
|
||||
"/:bind$i(?!\d)/",
|
||||
$this->quoteSmart($data[$key]),
|
||||
$this->last_query,
|
||||
1
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
if ($this->autocommit) {
|
||||
@ -708,9 +724,10 @@ class DB_oci8 extends DB_common
|
||||
* @return int DB_OK on success. A DB_Error object if the driver
|
||||
* doesn't support auto-committing transactions.
|
||||
*/
|
||||
function autoCommit($onoff = false)
|
||||
public function autoCommit($onoff = false)
|
||||
{
|
||||
$this->autocommit = (bool)$onoff;;
|
||||
$this->autocommit = (bool)$onoff;
|
||||
;
|
||||
return DB_OK;
|
||||
}
|
||||
|
||||
@ -722,7 +739,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function commit()
|
||||
public function commit()
|
||||
{
|
||||
$result = @OCICommit($this->connection);
|
||||
if (!$result) {
|
||||
@ -739,7 +756,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function rollback()
|
||||
public function rollback()
|
||||
{
|
||||
$result = @OCIRollback($this->connection);
|
||||
if (!$result) {
|
||||
@ -758,7 +775,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
if ($this->last_stmt === false) {
|
||||
return $this->oci8RaiseError();
|
||||
@ -784,7 +801,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function modifyQuery($query)
|
||||
public function modifyQuery($query)
|
||||
{
|
||||
if (preg_match('/^\s*SELECT/i', $query) &&
|
||||
!preg_match('/\sFROM\s/i', $query)) {
|
||||
@ -812,7 +829,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
{
|
||||
// Let Oracle return the name of the columns instead of
|
||||
// coding a "home" SQL parser
|
||||
@ -836,7 +853,7 @@ class DB_oci8 extends DB_common
|
||||
|
||||
$ncols = OCINumCols($result);
|
||||
$cols = array();
|
||||
for ( $i = 1; $i <= $ncols; $i++ ) {
|
||||
for ($i = 1; $i <= $ncols; $i++) {
|
||||
$cols[] = '"' . OCIColumnName($result, $i) . '"';
|
||||
}
|
||||
$fields = implode(', ', $cols);
|
||||
@ -874,7 +891,7 @@ class DB_oci8 extends DB_common
|
||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||
* DB_oci8::createSequence(), DB_oci8::dropSequence()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
$repeat = 0;
|
||||
@ -910,7 +927,7 @@ class DB_oci8 extends DB_common
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_oci8::nextID(), DB_oci8::dropSequence()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
return $this->query('CREATE SEQUENCE '
|
||||
. $this->getSequenceName($seq_name));
|
||||
@ -929,7 +946,7 @@ class DB_oci8 extends DB_common
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_oci8::nextID(), DB_oci8::createSequence()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->query('DROP SEQUENCE '
|
||||
. $this->getSequenceName($seq_name));
|
||||
@ -950,16 +967,26 @@ class DB_oci8 extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_oci8::errorNative(), DB_oci8::errorCode()
|
||||
*/
|
||||
function oci8RaiseError($errno = null)
|
||||
public function oci8RaiseError($errno = null)
|
||||
{
|
||||
if ($errno === null) {
|
||||
$error = @OCIError($this->connection);
|
||||
return $this->raiseError($this->errorCode($error['code']),
|
||||
null, null, null, $error['message']);
|
||||
return $this->raiseError(
|
||||
$this->errorCode($error['code']),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$error['message']
|
||||
);
|
||||
} elseif (is_resource($errno)) {
|
||||
$error = @OCIError($errno);
|
||||
return $this->raiseError($this->errorCode($error['code']),
|
||||
null, null, null, $error['message']);
|
||||
return $this->raiseError(
|
||||
$this->errorCode($error['code']),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$error['message']
|
||||
);
|
||||
}
|
||||
return $this->raiseError($this->errorCode($errno));
|
||||
}
|
||||
@ -973,7 +1000,7 @@ class DB_oci8 extends DB_common
|
||||
* @return int the DBMS' error code. FALSE if the code could not be
|
||||
* determined
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
if (is_resource($this->last_stmt)) {
|
||||
$error = @OCIError($this->last_stmt);
|
||||
@ -1009,7 +1036,7 @@ class DB_oci8 extends DB_common
|
||||
*
|
||||
* @see DB_common::tableInfo()
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
|
||||
$case_func = 'strtolower';
|
||||
@ -1061,7 +1088,6 @@ class DB_oci8 extends DB_common
|
||||
$res['num_fields'] = $i;
|
||||
}
|
||||
@OCIFreeStatement($stmt);
|
||||
|
||||
} else {
|
||||
if (isset($result->result)) {
|
||||
/*
|
||||
@ -1114,7 +1140,7 @@ class DB_oci8 extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'tables':
|
||||
@ -1140,12 +1166,12 @@ class DB_oci8 extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since release 1.7.8.
|
||||
*/
|
||||
function quoteFloat($float) {
|
||||
public function quoteFloat($float)
|
||||
{
|
||||
return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1154,5 +1180,3 @@ class DB_oci8 extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -55,13 +55,13 @@ class DB_odbc extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'odbc';
|
||||
public $phptype = 'odbc';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'sql92';
|
||||
public $dbsyntax = 'sql92';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -81,7 +81,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => 'emulate',
|
||||
'new_link' => false,
|
||||
'numrows' => true,
|
||||
@ -95,7 +95,7 @@ class DB_odbc extends DB_common
|
||||
* A mapping of native error codes to DB error codes
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
'01004' => DB_ERROR_TRUNCATED,
|
||||
'07001' => DB_ERROR_MISMATCH,
|
||||
'21S01' => DB_ERROR_VALUE_COUNT_ON_ROW,
|
||||
@ -132,13 +132,13 @@ class DB_odbc extends DB_common
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -146,7 +146,7 @@ class DB_odbc extends DB_common
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $affected = 0;
|
||||
public $affected = 0;
|
||||
|
||||
|
||||
// }}}
|
||||
@ -157,7 +157,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -178,7 +178,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('odbc')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
@ -213,18 +213,28 @@ class DB_odbc extends DB_common
|
||||
$connect_function = $persistent ? 'odbc_pconnect' : 'odbc_connect';
|
||||
|
||||
if (empty($dsn['cursor'])) {
|
||||
$this->connection = @$connect_function($odbcdsn, $dsn['username'],
|
||||
$dsn['password']);
|
||||
$this->connection = @$connect_function(
|
||||
$odbcdsn,
|
||||
$dsn['username'],
|
||||
$dsn['password']
|
||||
);
|
||||
} else {
|
||||
$this->connection = @$connect_function($odbcdsn, $dsn['username'],
|
||||
$this->connection = @$connect_function(
|
||||
$odbcdsn,
|
||||
$dsn['username'],
|
||||
$dsn['password'],
|
||||
$dsn['cursor']);
|
||||
$dsn['cursor']
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_resource($this->connection)) {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$this->errorNative());
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$this->errorNative()
|
||||
);
|
||||
}
|
||||
return DB_OK;
|
||||
}
|
||||
@ -237,7 +247,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$err = @odbc_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -256,7 +266,7 @@ class DB_odbc extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$this->last_query = $query;
|
||||
$query = $this->modifyQuery($query);
|
||||
@ -286,7 +296,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @return true if a result is available otherwise return false
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return @odbc_next_result($result);
|
||||
}
|
||||
@ -314,7 +324,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
$arr = array();
|
||||
if ($rownum !== null) {
|
||||
@ -365,7 +375,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
return is_resource($result) ? odbc_free_result($result) : false;
|
||||
}
|
||||
@ -386,7 +396,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
$cols = @odbc_num_fields($result);
|
||||
if (!$cols) {
|
||||
@ -405,7 +415,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
if (empty($this->affected)) { // In case of SELECT stms
|
||||
return 0;
|
||||
@ -436,7 +446,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @see DB_result::numRows()
|
||||
*/
|
||||
function numRows($result)
|
||||
public function numRows($result)
|
||||
{
|
||||
$nrows = @odbc_num_rows($result);
|
||||
if ($nrows == -1) {
|
||||
@ -464,7 +474,7 @@ class DB_odbc extends DB_common
|
||||
* @see DB_common::quoteIdentifier()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function quoteIdentifier($str)
|
||||
public function quoteIdentifier($str)
|
||||
{
|
||||
switch ($this->dsn['dbsyntax']) {
|
||||
case 'access':
|
||||
@ -496,7 +506,7 @@ class DB_odbc extends DB_common
|
||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||
* DB_odbc::createSequence(), DB_odbc::dropSequence()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
$repeat = 0;
|
||||
@ -546,7 +556,7 @@ class DB_odbc extends DB_common
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_odbc::nextID(), DB_odbc::dropSequence()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
return $this->query('CREATE TABLE '
|
||||
. $this->getSequenceName($seq_name)
|
||||
@ -567,7 +577,7 @@ class DB_odbc extends DB_common
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_odbc::nextID(), DB_odbc::createSequence()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
|
||||
}
|
||||
@ -583,7 +593,7 @@ class DB_odbc extends DB_common
|
||||
* @return int DB_OK on success. A DB_Error object if the driver
|
||||
* doesn't support auto-committing transactions.
|
||||
*/
|
||||
function autoCommit($onoff = false)
|
||||
public function autoCommit($onoff = false)
|
||||
{
|
||||
if (!@odbc_autocommit($this->connection, $onoff)) {
|
||||
return $this->odbcRaiseError();
|
||||
@ -599,7 +609,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function commit()
|
||||
public function commit()
|
||||
{
|
||||
if (!@odbc_commit($this->connection)) {
|
||||
return $this->odbcRaiseError();
|
||||
@ -615,7 +625,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function rollback()
|
||||
public function rollback()
|
||||
{
|
||||
if (!@odbc_rollback($this->connection)) {
|
||||
return $this->odbcRaiseError();
|
||||
@ -638,7 +648,7 @@ class DB_odbc extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_odbc::errorNative(), DB_common::errorCode()
|
||||
*/
|
||||
function odbcRaiseError($errno = null)
|
||||
public function odbcRaiseError($errno = null)
|
||||
{
|
||||
if ($errno === null) {
|
||||
switch ($this->dbsyntax) {
|
||||
@ -664,9 +674,13 @@ class DB_odbc extends DB_common
|
||||
}
|
||||
foreach ($error_regexps as $regexp => $code) {
|
||||
if (preg_match($regexp, $errormsg)) {
|
||||
return $this->raiseError($code,
|
||||
null, null, null,
|
||||
$native_code . ' ' . $errormsg);
|
||||
return $this->raiseError(
|
||||
$code,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$native_code . ' ' . $errormsg
|
||||
);
|
||||
}
|
||||
}
|
||||
$errno = DB_ERROR;
|
||||
@ -678,8 +692,13 @@ class DB_odbc extends DB_common
|
||||
$errno = $this->errorCode(odbc_error($this->connection));
|
||||
}
|
||||
}
|
||||
return $this->raiseError($errno, null, null, null,
|
||||
$this->errorNative());
|
||||
return $this->raiseError(
|
||||
$errno,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$this->errorNative()
|
||||
);
|
||||
}
|
||||
|
||||
// }}}
|
||||
@ -690,7 +709,7 @@ class DB_odbc extends DB_common
|
||||
*
|
||||
* @return string the DBMS' error code and message
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
if (!is_resource($this->connection)) {
|
||||
return @odbc_error() . ' ' . @odbc_errormsg();
|
||||
@ -717,7 +736,7 @@ class DB_odbc extends DB_common
|
||||
* @see DB_common::tableInfo()
|
||||
* @since Method available since Release 1.7.0
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
/*
|
||||
@ -803,7 +822,7 @@ class DB_odbc extends DB_common
|
||||
* @see DB_common::getListOf()
|
||||
* @since Method available since Release 1.7.0
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'databases':
|
||||
@ -813,9 +832,10 @@ class DB_odbc extends DB_common
|
||||
$res = @odbc_data_source($this->connection, SQL_FETCH_FIRST);
|
||||
if (is_array($res)) {
|
||||
$out = array($res['server']);
|
||||
while($res = @odbc_data_source($this->connection,
|
||||
SQL_FETCH_NEXT))
|
||||
{
|
||||
while ($res = @odbc_data_source(
|
||||
$this->connection,
|
||||
SQL_FETCH_NEXT
|
||||
)) {
|
||||
$out[] = $res['server'];
|
||||
}
|
||||
return $out;
|
||||
@ -858,7 +878,6 @@ class DB_odbc extends DB_common
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -867,5 +886,3 @@ class DB_odbc extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -54,13 +54,13 @@ class DB_pgsql extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'pgsql';
|
||||
public $phptype = 'pgsql';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'pgsql';
|
||||
public $dbsyntax = 'pgsql';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -75,7 +75,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => 'alter',
|
||||
'new_link' => '4.3.0',
|
||||
'numrows' => true,
|
||||
@ -89,20 +89,20 @@ class DB_pgsql extends DB_common
|
||||
* A mapping of native error codes to DB error codes
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
);
|
||||
|
||||
/**
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -110,7 +110,7 @@ class DB_pgsql extends DB_common
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $autocommit = true;
|
||||
public $autocommit = true;
|
||||
|
||||
/**
|
||||
* The quantity of transactions begun
|
||||
@ -121,27 +121,27 @@ class DB_pgsql extends DB_common
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $transaction_opcount = 0;
|
||||
public $transaction_opcount = 0;
|
||||
|
||||
/**
|
||||
* The number of rows affected by a data manipulation query
|
||||
* @var integer
|
||||
*/
|
||||
var $affected = 0;
|
||||
public $affected = 0;
|
||||
|
||||
/**
|
||||
* The current row being looked at in fetchInto()
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $row = array();
|
||||
public $row = array();
|
||||
|
||||
/**
|
||||
* The number of rows in a given result set
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_num_rows = array();
|
||||
public $_num_rows = array();
|
||||
|
||||
|
||||
// }}}
|
||||
@ -152,7 +152,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -206,7 +206,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @link http://www.postgresql.org/docs/current/static/libpq.html#LIBPQ-CONNECT
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('pgsql')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
@ -262,8 +262,7 @@ class DB_pgsql extends DB_common
|
||||
}
|
||||
|
||||
if (isset($dsn['new_link'])
|
||||
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true))
|
||||
{
|
||||
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true)) {
|
||||
if (version_compare(phpversion(), '4.3.0', '>=')) {
|
||||
$params[] = PGSQL_CONNECT_FORCE_NEW;
|
||||
}
|
||||
@ -274,19 +273,27 @@ class DB_pgsql extends DB_common
|
||||
$ini = ini_get('track_errors');
|
||||
$php_errormsg = '';
|
||||
if ($ini) {
|
||||
$this->connection = @call_user_func_array($connect_function,
|
||||
$params);
|
||||
$this->connection = @call_user_func_array(
|
||||
$connect_function,
|
||||
$params
|
||||
);
|
||||
} else {
|
||||
@ini_set('track_errors', 1);
|
||||
$this->connection = @call_user_func_array($connect_function,
|
||||
$params);
|
||||
$this->connection = @call_user_func_array(
|
||||
$connect_function,
|
||||
$params
|
||||
);
|
||||
@ini_set('track_errors', $ini);
|
||||
}
|
||||
|
||||
if (!$this->connection) {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
$php_errormsg);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$php_errormsg
|
||||
);
|
||||
}
|
||||
return DB_OK;
|
||||
}
|
||||
@ -299,7 +306,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$ret = @pg_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -318,7 +325,7 @@ class DB_pgsql extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$ismanip = $this->_checkManip($query);
|
||||
$this->last_query = $query;
|
||||
@ -353,9 +360,10 @@ class DB_pgsql extends DB_common
|
||||
if ($ismanip) {
|
||||
$this->affected = @pg_affected_rows($result);
|
||||
return DB_OK;
|
||||
} elseif (preg_match('/^\s*\(*\s*(SELECT|EXPLAIN|FETCH|SHOW|WITH)\s/si',
|
||||
$query))
|
||||
{
|
||||
} elseif (preg_match(
|
||||
'/^\s*\(*\s*(SELECT|EXPLAIN|FETCH|SHOW|WITH)\s/si',
|
||||
$query
|
||||
)) {
|
||||
$this->row[(int)$result] = 0; // reset the row counter.
|
||||
$numrows = $this->numRows($result);
|
||||
if (is_object($numrows)) {
|
||||
@ -382,7 +390,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @return true if a result is available otherwise return false
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -410,7 +418,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
$result_int = (int)$result;
|
||||
$rownum = ($rownum !== null) ? $rownum : $this->row[$result_int];
|
||||
@ -454,7 +462,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
if (is_resource($result)) {
|
||||
unset($this->row[(int)$result]);
|
||||
@ -477,7 +485,8 @@ class DB_pgsql extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since release 1.7.8.
|
||||
*/
|
||||
function quoteBoolean($boolean) {
|
||||
public function quoteBoolean($boolean)
|
||||
{
|
||||
return $boolean ? 'TRUE' : 'FALSE';
|
||||
}
|
||||
|
||||
@ -497,7 +506,7 @@ class DB_pgsql extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function escapeSimple($str)
|
||||
public function escapeSimple($str)
|
||||
{
|
||||
if (function_exists('pg_escape_string')) {
|
||||
/* This fixes an undocumented BC break in PHP 5.2.0 which changed
|
||||
@ -532,7 +541,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
$cols = @pg_numfields($result);
|
||||
if (!$cols) {
|
||||
@ -557,7 +566,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @see DB_result::numRows()
|
||||
*/
|
||||
function numRows($result)
|
||||
public function numRows($result)
|
||||
{
|
||||
$rows = @pg_numrows($result);
|
||||
if ($rows === null) {
|
||||
@ -577,7 +586,7 @@ class DB_pgsql extends DB_common
|
||||
* @return int DB_OK on success. A DB_Error object if the driver
|
||||
* doesn't support auto-committing transactions.
|
||||
*/
|
||||
function autoCommit($onoff = false)
|
||||
public function autoCommit($onoff = false)
|
||||
{
|
||||
// XXX if $this->transaction_opcount > 0, we should probably
|
||||
// issue a warning here.
|
||||
@ -593,7 +602,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function commit()
|
||||
public function commit()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
// (disabled) hack to shut up error messages from libpq.a
|
||||
@ -615,7 +624,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function rollback()
|
||||
public function rollback()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
$result = @pg_exec($this->connection, 'abort;');
|
||||
@ -637,7 +646,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
return $this->affected;
|
||||
}
|
||||
@ -658,7 +667,7 @@ class DB_pgsql extends DB_common
|
||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||
* DB_pgsql::createSequence(), DB_pgsql::dropSequence()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
$repeat = false;
|
||||
@ -700,7 +709,7 @@ class DB_pgsql extends DB_common
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_pgsql::nextID(), DB_pgsql::dropSequence()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
$result = $this->query("CREATE SEQUENCE ${seqname}");
|
||||
@ -720,7 +729,7 @@ class DB_pgsql extends DB_common
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_pgsql::nextID(), DB_pgsql::createSequence()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->query('DROP SEQUENCE '
|
||||
. $this->getSequenceName($seq_name));
|
||||
@ -745,7 +754,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
{
|
||||
return "$query LIMIT $count OFFSET $from";
|
||||
}
|
||||
@ -765,7 +774,7 @@ class DB_pgsql extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_pgsql::errorNative(), DB_pgsql::errorCode()
|
||||
*/
|
||||
function pgsqlRaiseError($errno = null)
|
||||
public function pgsqlRaiseError($errno = null)
|
||||
{
|
||||
$native = $this->errorNative();
|
||||
if (!$native) {
|
||||
@ -789,7 +798,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @return string the DBMS' error message
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
return @pg_errormessage($this->connection);
|
||||
}
|
||||
@ -803,7 +812,7 @@ class DB_pgsql extends DB_common
|
||||
* @param string $errormsg error message returned from the database
|
||||
* @return integer an error number from a DB error constant
|
||||
*/
|
||||
function errorCode($errormsg)
|
||||
public function errorCode($errormsg)
|
||||
{
|
||||
static $error_regexps;
|
||||
if (!isset($error_regexps)) {
|
||||
@ -880,7 +889,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @see DB_common::tableInfo()
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
/*
|
||||
@ -965,7 +974,7 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _pgFieldFlags($resource, $num_field, $table_name)
|
||||
public function _pgFieldFlags($resource, $num_field, $table_name)
|
||||
{
|
||||
$field_name = @pg_fieldname($resource, $num_field);
|
||||
|
||||
@ -1019,10 +1028,11 @@ class DB_pgsql extends DB_common
|
||||
if (in_array($num_field + 1, $keys)) {
|
||||
$flags .= ($row[0] == 't' && $row[1] == 'f') ? 'unique_key ' : '';
|
||||
$flags .= ($row[1] == 't') ? 'primary_key ' : '';
|
||||
if (count($keys) > 1)
|
||||
if (count($keys) > 1) {
|
||||
$flags .= 'multiple_key ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return trim($flags);
|
||||
}
|
||||
@ -1041,7 +1051,7 @@ class DB_pgsql extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'tables':
|
||||
@ -1105,12 +1115,11 @@ class DB_pgsql extends DB_common
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function _checkManip($query)
|
||||
public function _checkManip($query)
|
||||
{
|
||||
return (preg_match('/^\s*(SAVEPOINT|RELEASE)\s+/i', $query)
|
||||
|| parent::_checkManip($query));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1119,5 +1128,3 @@ class DB_pgsql extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -58,13 +58,13 @@ class DB_sqlite extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'sqlite';
|
||||
public $phptype = 'sqlite';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'sqlite';
|
||||
public $dbsyntax = 'sqlite';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -79,7 +79,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => 'alter',
|
||||
'new_link' => false,
|
||||
'numrows' => true,
|
||||
@ -98,20 +98,20 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
);
|
||||
|
||||
/**
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -121,7 +121,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $keywords = array (
|
||||
public $keywords = array(
|
||||
'BLOB' => '',
|
||||
'BOOLEAN' => '',
|
||||
'CHARACTER' => '',
|
||||
@ -145,7 +145,7 @@ class DB_sqlite extends DB_common
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_lasterror = '';
|
||||
public $_lasterror = '';
|
||||
|
||||
|
||||
// }}}
|
||||
@ -156,7 +156,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -193,7 +193,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('sqlite')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
@ -214,8 +214,7 @@ class DB_sqlite extends DB_common
|
||||
return $this->sqliteRaiseError(DB_ERROR_NOT_FOUND);
|
||||
}
|
||||
if (!isset($dsn['mode']) ||
|
||||
!is_numeric($dsn['mode']))
|
||||
{
|
||||
!is_numeric($dsn['mode'])) {
|
||||
$mode = 0644;
|
||||
} else {
|
||||
$mode = octdec($dsn['mode']);
|
||||
@ -242,9 +241,13 @@ class DB_sqlite extends DB_common
|
||||
$php_errormsg = '';
|
||||
|
||||
if (!$this->connection = @$connect_function($dsn['database'])) {
|
||||
return $this->raiseError(DB_ERROR_NODBSELECTED,
|
||||
null, null, null,
|
||||
$php_errormsg);
|
||||
return $this->raiseError(
|
||||
DB_ERROR_NODBSELECTED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$php_errormsg
|
||||
);
|
||||
}
|
||||
return DB_OK;
|
||||
}
|
||||
@ -257,7 +260,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$ret = @sqlite_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -280,7 +283,7 @@ class DB_sqlite extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$ismanip = $this->_checkManip($query);
|
||||
$this->last_query = $query;
|
||||
@ -319,7 +322,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @return bool true if a result is available otherwise return false
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -347,7 +350,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
if ($rownum !== null) {
|
||||
if (!@sqlite_seek($this->result, $rownum)) {
|
||||
@ -405,7 +408,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult(&$result)
|
||||
public function freeResult(&$result)
|
||||
{
|
||||
// XXX No native free?
|
||||
if (!is_resource($result)) {
|
||||
@ -431,7 +434,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
$cols = @sqlite_num_fields($result);
|
||||
if (!$cols) {
|
||||
@ -456,7 +459,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @see DB_result::numRows()
|
||||
*/
|
||||
function numRows($result)
|
||||
public function numRows($result)
|
||||
{
|
||||
$rows = @sqlite_num_rows($result);
|
||||
if ($rows === null) {
|
||||
@ -475,7 +478,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
return @sqlite_changes($this->connection);
|
||||
}
|
||||
@ -493,7 +496,7 @@ class DB_sqlite extends DB_common
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_sqlite::nextID(), DB_sqlite::createSequence()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
|
||||
}
|
||||
@ -508,7 +511,7 @@ class DB_sqlite extends DB_common
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_sqlite::nextID(), DB_sqlite::dropSequence()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
$query = 'CREATE TABLE ' . $seqname .
|
||||
@ -543,7 +546,7 @@ class DB_sqlite extends DB_common
|
||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||
* DB_sqlite::createSequence(), DB_sqlite::dropSequence()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
|
||||
@ -558,8 +561,7 @@ class DB_sqlite extends DB_common
|
||||
return $id;
|
||||
}
|
||||
} elseif ($ondemand && DB::isError($result) &&
|
||||
$result->getCode() == DB_ERROR_NOSUCHTABLE)
|
||||
{
|
||||
$result->getCode() == DB_ERROR_NOSUCHTABLE) {
|
||||
$result = $this->createSequence($seq_name);
|
||||
if (DB::isError($result)) {
|
||||
return $this->raiseError($result);
|
||||
@ -587,7 +589,7 @@ class DB_sqlite extends DB_common
|
||||
* @return mixed an array on an unspecified key, integer on a passed
|
||||
* arg and false at a stats error
|
||||
*/
|
||||
function getDbFileStats($arg = '')
|
||||
public function getDbFileStats($arg = '')
|
||||
{
|
||||
$stats = stat($this->dsn['database']);
|
||||
if ($stats == false) {
|
||||
@ -625,7 +627,7 @@ class DB_sqlite extends DB_common
|
||||
* @since Method available since Release 1.6.1
|
||||
* @see DB_common::escapeSimple()
|
||||
*/
|
||||
function escapeSimple($str)
|
||||
public function escapeSimple($str)
|
||||
{
|
||||
return @sqlite_escape_string($str);
|
||||
}
|
||||
@ -649,7 +651,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||
{
|
||||
return "$query LIMIT $count OFFSET $from";
|
||||
}
|
||||
@ -671,12 +673,15 @@ class DB_sqlite extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::setOption()
|
||||
*/
|
||||
function modifyQuery($query)
|
||||
public function modifyQuery($query)
|
||||
{
|
||||
if ($this->options['portability'] & DB_PORTABILITY_DELETE_COUNT) {
|
||||
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) {
|
||||
$query = preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/',
|
||||
'DELETE FROM \1 WHERE 1=1', $query);
|
||||
$query = preg_replace(
|
||||
'/^\s*DELETE\s+FROM\s+(\S+)\s*$/',
|
||||
'DELETE FROM \1 WHERE 1=1',
|
||||
$query
|
||||
);
|
||||
}
|
||||
}
|
||||
return $query;
|
||||
@ -697,7 +702,7 @@ class DB_sqlite extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_sqlite::errorNative(), DB_sqlite::errorCode()
|
||||
*/
|
||||
function sqliteRaiseError($errno = null)
|
||||
public function sqliteRaiseError($errno = null)
|
||||
{
|
||||
$native = $this->errorNative();
|
||||
if ($errno === null) {
|
||||
@ -721,7 +726,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @return string the DBMS' error message
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
return $this->_lasterror;
|
||||
}
|
||||
@ -736,7 +741,7 @@ class DB_sqlite extends DB_common
|
||||
*
|
||||
* @return integer the DB error number
|
||||
*/
|
||||
function errorCode($errormsg)
|
||||
public function errorCode($errormsg)
|
||||
{
|
||||
static $error_regexps;
|
||||
|
||||
@ -785,22 +790,29 @@ class DB_sqlite extends DB_common
|
||||
* @see DB_common::tableInfo()
|
||||
* @since Method available since Release 1.7.0
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
/*
|
||||
* Probably received a table name.
|
||||
* Create a result resource identifier.
|
||||
*/
|
||||
$id = @sqlite_array_query($this->connection,
|
||||
$id = @sqlite_array_query(
|
||||
$this->connection,
|
||||
"PRAGMA table_info('$result');",
|
||||
SQLITE_ASSOC);
|
||||
SQLITE_ASSOC
|
||||
);
|
||||
$got_string = true;
|
||||
} else {
|
||||
$this->last_query = '';
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE, null, null, null,
|
||||
return $this->raiseError(
|
||||
DB_ERROR_NOT_CAPABLE,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
'This DBMS can not obtain tableInfo' .
|
||||
' from result sets');
|
||||
' from result sets'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
|
||||
@ -820,7 +832,7 @@ class DB_sqlite extends DB_common
|
||||
if (strpos($id[$i]['type'], '(') !== false) {
|
||||
$bits = explode('(', $id[$i]['type']);
|
||||
$type = $bits[0];
|
||||
$len = rtrim($bits[1],')');
|
||||
$len = rtrim($bits[1], ')');
|
||||
} else {
|
||||
$type = $id[$i]['type'];
|
||||
$len = 0;
|
||||
@ -877,11 +889,16 @@ class DB_sqlite extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type, $args = array())
|
||||
public function getSpecialQuery($type, $args = array())
|
||||
{
|
||||
if (!is_array($args)) {
|
||||
return $this->raiseError('no key specified', null, null, null,
|
||||
'Argument has to be an array.');
|
||||
return $this->raiseError(
|
||||
'no key specified',
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
'Argument has to be an array.'
|
||||
);
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
@ -959,5 +976,3 @@ class DB_sqlite extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -47,33 +47,33 @@ class DB_storage extends PEAR
|
||||
|
||||
/** the name of the table (or view, if the backend database supports
|
||||
updates in views) we hold data from */
|
||||
var $_table = null;
|
||||
public $_table = null;
|
||||
|
||||
/** which column(s) in the table contains primary keys, can be a
|
||||
string for single-column primary keys, or an array of strings
|
||||
for multiple-column primary keys */
|
||||
var $_keycolumn = null;
|
||||
public $_keycolumn = null;
|
||||
|
||||
/** DB connection handle used for all transactions */
|
||||
var $_dbh = null;
|
||||
public $_dbh = null;
|
||||
|
||||
/** an assoc with the names of database fields stored as properties
|
||||
in this object */
|
||||
var $_properties = array();
|
||||
public $_properties = array();
|
||||
|
||||
/** an assoc with the names of the properties in this object that
|
||||
have been changed since they were fetched from the database */
|
||||
var $_changes = array();
|
||||
public $_changes = array();
|
||||
|
||||
/** flag that decides if data in this object can be changed.
|
||||
objects that don't have their table's key column in their
|
||||
property lists will be flagged as read-only. */
|
||||
var $_readonly = false;
|
||||
public $_readonly = false;
|
||||
|
||||
/** function or method that implements a validator for fields that
|
||||
are set, this validator function returns true if the field is
|
||||
valid, false if not */
|
||||
var $_validator = null;
|
||||
public $_validator = null;
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
@ -94,7 +94,7 @@ class DB_storage extends PEAR
|
||||
* a reference to this object
|
||||
*
|
||||
*/
|
||||
function __construct($table, $keycolumn, &$dbh, $validator = null)
|
||||
public function __construct($table, $keycolumn, &$dbh, $validator = null)
|
||||
{
|
||||
$this->PEAR('DB_Error');
|
||||
$this->_table = $table;
|
||||
@ -115,7 +115,7 @@ class DB_storage extends PEAR
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _makeWhere($keyval = null)
|
||||
public function _makeWhere($keyval = null)
|
||||
{
|
||||
if (is_array($this->_keycolumn)) {
|
||||
if ($keyval === null) {
|
||||
@ -164,7 +164,7 @@ class DB_storage extends PEAR
|
||||
*
|
||||
* @return int DB_OK on success, a DB error if not
|
||||
*/
|
||||
function setup($keyval)
|
||||
public function setup($keyval)
|
||||
{
|
||||
$whereclause = $this->_makeWhere($keyval);
|
||||
$query = 'SELECT * FROM ' . $this->_table . ' WHERE ' . $whereclause;
|
||||
@ -177,8 +177,15 @@ class DB_storage extends PEAR
|
||||
return $row;
|
||||
}
|
||||
if (!$row) {
|
||||
return $this->raiseError(null, DB_ERROR_NOT_FOUND, null, null,
|
||||
$query, null, true);
|
||||
return $this->raiseError(
|
||||
null,
|
||||
DB_ERROR_NOT_FOUND,
|
||||
null,
|
||||
null,
|
||||
$query,
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
foreach ($row as $key => $value) {
|
||||
$this->_properties[$key] = true;
|
||||
@ -194,7 +201,7 @@ class DB_storage extends PEAR
|
||||
* Create a new (empty) row in the configured table for this
|
||||
* object.
|
||||
*/
|
||||
function insert($newpk)
|
||||
public function insert($newpk)
|
||||
{
|
||||
if (is_array($this->_keycolumn)) {
|
||||
$primarykey = $this->_keycolumn;
|
||||
@ -225,7 +232,7 @@ class DB_storage extends PEAR
|
||||
* Output a simple description of this DB_storage object.
|
||||
* @return string object description
|
||||
*/
|
||||
function toString()
|
||||
public function toString()
|
||||
{
|
||||
$info = strtolower(get_class($this));
|
||||
$info .= " (table=";
|
||||
@ -272,7 +279,7 @@ class DB_storage extends PEAR
|
||||
/**
|
||||
* Dump the contents of this object to "standard output".
|
||||
*/
|
||||
function dump()
|
||||
public function dump()
|
||||
{
|
||||
foreach ($this->_properties as $prop => $foo) {
|
||||
print "$prop = ";
|
||||
@ -290,7 +297,7 @@ class DB_storage extends PEAR
|
||||
* of properties/columns
|
||||
* @return object a new instance of DB_storage or a subclass of it
|
||||
*/
|
||||
function &create($table, &$data)
|
||||
public function &create($table, &$data)
|
||||
{
|
||||
$classname = strtolower(get_class($this));
|
||||
$obj = new $classname($table);
|
||||
@ -319,8 +326,8 @@ class DB_storage extends PEAR
|
||||
* key column was not found among the columns returned by $query),
|
||||
* or another DB error code in case of errors.
|
||||
*/
|
||||
// XXX commented out for now
|
||||
/*
|
||||
// XXX commented out for now
|
||||
/*
|
||||
function loadFromQuery($query, $params = null)
|
||||
{
|
||||
if (sizeof($this->_properties)) {
|
||||
@ -359,24 +366,33 @@ class DB_storage extends PEAR
|
||||
/**
|
||||
* Modify an attriute value.
|
||||
*/
|
||||
function set($property, $newvalue)
|
||||
public function set($property, $newvalue)
|
||||
{
|
||||
// only change if $property is known and object is not
|
||||
// read-only
|
||||
if ($this->_readonly) {
|
||||
return $this->raiseError(null, DB_WARNING_READ_ONLY, null,
|
||||
null, null, null, true);
|
||||
return $this->raiseError(
|
||||
null,
|
||||
DB_WARNING_READ_ONLY,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
if (@isset($this->_properties[$property])) {
|
||||
if (empty($this->_validator)) {
|
||||
$valid = true;
|
||||
} else {
|
||||
$valid = @call_user_func($this->_validator,
|
||||
$valid = @call_user_func(
|
||||
$this->_validator,
|
||||
$this->_table,
|
||||
$property,
|
||||
$newvalue,
|
||||
$this->$property,
|
||||
$this);
|
||||
$this
|
||||
);
|
||||
}
|
||||
if ($valid) {
|
||||
$this->$property = $newvalue;
|
||||
@ -386,15 +402,27 @@ class DB_storage extends PEAR
|
||||
$this->_changes[$property]++;
|
||||
}
|
||||
} else {
|
||||
return $this->raiseError(null, DB_ERROR_INVALID, null,
|
||||
null, "invalid field: $property",
|
||||
null, true);
|
||||
return $this->raiseError(
|
||||
null,
|
||||
DB_ERROR_INVALID,
|
||||
null,
|
||||
null,
|
||||
"invalid field: $property",
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return $this->raiseError(null, DB_ERROR_NOSUCHFIELD, null,
|
||||
null, "unknown field: $property",
|
||||
null, true);
|
||||
return $this->raiseError(
|
||||
null,
|
||||
DB_ERROR_NOSUCHFIELD,
|
||||
null,
|
||||
null,
|
||||
"unknown field: $property",
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
// }}}
|
||||
@ -408,7 +436,7 @@ class DB_storage extends PEAR
|
||||
* @return attribute contents, or null if the attribute name is
|
||||
* unknown
|
||||
*/
|
||||
function &get($property)
|
||||
public function &get($property)
|
||||
{
|
||||
// only return if $property is known
|
||||
if (isset($this->_properties[$property])) {
|
||||
@ -425,7 +453,7 @@ class DB_storage extends PEAR
|
||||
* Destructor, calls DB_storage::store() if there are changes
|
||||
* that are to be kept.
|
||||
*/
|
||||
function _DB_storage()
|
||||
public function _DB_storage()
|
||||
{
|
||||
if (sizeof($this->_changes)) {
|
||||
$this->store();
|
||||
@ -443,7 +471,7 @@ class DB_storage extends PEAR
|
||||
*
|
||||
* @return DB_OK or a DB error
|
||||
*/
|
||||
function store()
|
||||
public function store()
|
||||
{
|
||||
$params = array();
|
||||
$vars = array();
|
||||
@ -473,11 +501,18 @@ class DB_storage extends PEAR
|
||||
*
|
||||
* @return mixed DB_OK or a DB error
|
||||
*/
|
||||
function remove()
|
||||
public function remove()
|
||||
{
|
||||
if ($this->_readonly) {
|
||||
return $this->raiseError(null, DB_WARNING_READ_ONLY, null,
|
||||
null, null, null, true);
|
||||
return $this->raiseError(
|
||||
null,
|
||||
DB_WARNING_READ_ONLY,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
$query = 'DELETE FROM ' . $this->_table .' WHERE '.
|
||||
$this->_makeWhere();
|
||||
@ -502,5 +537,3 @@ class DB_storage extends PEAR
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
@ -57,13 +57,13 @@ class DB_sybase extends DB_common
|
||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||
* @var string
|
||||
*/
|
||||
var $phptype = 'sybase';
|
||||
public $phptype = 'sybase';
|
||||
|
||||
/**
|
||||
* The database syntax variant to be used (db2, access, etc.), if any
|
||||
* @var string
|
||||
*/
|
||||
var $dbsyntax = 'sybase';
|
||||
public $dbsyntax = 'sybase';
|
||||
|
||||
/**
|
||||
* The capabilities of this DB implementation
|
||||
@ -78,7 +78,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $features = array(
|
||||
public $features = array(
|
||||
'limit' => 'emulate',
|
||||
'new_link' => false,
|
||||
'numrows' => true,
|
||||
@ -92,20 +92,20 @@ class DB_sybase extends DB_common
|
||||
* A mapping of native error codes to DB error codes
|
||||
* @var array
|
||||
*/
|
||||
var $errorcode_map = array(
|
||||
public $errorcode_map = array(
|
||||
);
|
||||
|
||||
/**
|
||||
* The raw database connection created by PHP
|
||||
* @var resource
|
||||
*/
|
||||
var $connection;
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The DSN information for connecting to a database
|
||||
* @var array
|
||||
*/
|
||||
var $dsn = array();
|
||||
public $dsn = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -113,7 +113,7 @@ class DB_sybase extends DB_common
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $autocommit = true;
|
||||
public $autocommit = true;
|
||||
|
||||
/**
|
||||
* The quantity of transactions begun
|
||||
@ -124,7 +124,7 @@ class DB_sybase extends DB_common
|
||||
* @var integer
|
||||
* @access private
|
||||
*/
|
||||
var $transaction_opcount = 0;
|
||||
public $transaction_opcount = 0;
|
||||
|
||||
/**
|
||||
* The database specified in the DSN
|
||||
@ -134,7 +134,7 @@ class DB_sybase extends DB_common
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_db = '';
|
||||
public $_db = '';
|
||||
|
||||
|
||||
// }}}
|
||||
@ -145,7 +145,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@ -169,11 +169,10 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function connect($dsn, $persistent = false)
|
||||
public function connect($dsn, $persistent = false)
|
||||
{
|
||||
if (!PEAR::loadExtension('sybase') &&
|
||||
!PEAR::loadExtension('sybase_ct'))
|
||||
{
|
||||
!PEAR::loadExtension('sybase_ct')) {
|
||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||
}
|
||||
|
||||
@ -190,28 +189,42 @@ class DB_sybase extends DB_common
|
||||
$connect_function = $persistent ? 'sybase_pconnect' : 'sybase_connect';
|
||||
|
||||
if ($dsn['username']) {
|
||||
$this->connection = @$connect_function($dsn['hostspec'],
|
||||
$this->connection = @$connect_function(
|
||||
$dsn['hostspec'],
|
||||
$dsn['username'],
|
||||
$dsn['password'],
|
||||
$dsn['charset'],
|
||||
$dsn['appname']);
|
||||
$dsn['appname']
|
||||
);
|
||||
} else {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
'The DSN did not contain a username.');
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
'The DSN did not contain a username.'
|
||||
);
|
||||
}
|
||||
|
||||
if (!$this->connection) {
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
||||
null, null, null,
|
||||
@sybase_get_last_message());
|
||||
return $this->raiseError(
|
||||
DB_ERROR_CONNECT_FAILED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@sybase_get_last_message()
|
||||
);
|
||||
}
|
||||
|
||||
if ($dsn['database']) {
|
||||
if (!@sybase_select_db($dsn['database'], $this->connection)) {
|
||||
return $this->raiseError(DB_ERROR_NODBSELECTED,
|
||||
null, null, null,
|
||||
@sybase_get_last_message());
|
||||
return $this->raiseError(
|
||||
DB_ERROR_NODBSELECTED,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@sybase_get_last_message()
|
||||
);
|
||||
}
|
||||
$this->_db = $dsn['database'];
|
||||
}
|
||||
@ -227,7 +240,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
function disconnect()
|
||||
public function disconnect()
|
||||
{
|
||||
$ret = @sybase_close($this->connection);
|
||||
$this->connection = null;
|
||||
@ -246,7 +259,7 @@ class DB_sybase extends DB_common
|
||||
* + the DB_OK constant for other successful queries
|
||||
* + a DB_Error object on failure
|
||||
*/
|
||||
function simpleQuery($query)
|
||||
public function simpleQuery($query)
|
||||
{
|
||||
$ismanip = $this->_checkManip($query);
|
||||
$this->last_query = $query;
|
||||
@ -287,7 +300,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @return true if a result is available otherwise return false
|
||||
*/
|
||||
function nextResult($result)
|
||||
public function nextResult($result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -315,7 +328,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @see DB_result::fetchInto()
|
||||
*/
|
||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||
{
|
||||
if ($rownum !== null) {
|
||||
if (!@sybase_data_seek($result, $rownum)) {
|
||||
@ -368,7 +381,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @see DB_result::free()
|
||||
*/
|
||||
function freeResult($result)
|
||||
public function freeResult($result)
|
||||
{
|
||||
return is_resource($result) ? sybase_free_result($result) : false;
|
||||
}
|
||||
@ -389,7 +402,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @see DB_result::numCols()
|
||||
*/
|
||||
function numCols($result)
|
||||
public function numCols($result)
|
||||
{
|
||||
$cols = @sybase_num_fields($result);
|
||||
if (!$cols) {
|
||||
@ -414,7 +427,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @see DB_result::numRows()
|
||||
*/
|
||||
function numRows($result)
|
||||
public function numRows($result)
|
||||
{
|
||||
$rows = @sybase_num_rows($result);
|
||||
if ($rows === false) {
|
||||
@ -433,7 +446,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @return int the number of rows. A DB_Error object on failure.
|
||||
*/
|
||||
function affectedRows()
|
||||
public function affectedRows()
|
||||
{
|
||||
if ($this->_last_query_manip) {
|
||||
$result = @sybase_affected_rows($this->connection);
|
||||
@ -459,7 +472,7 @@ class DB_sybase extends DB_common
|
||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||
* DB_sybase::createSequence(), DB_sybase::dropSequence()
|
||||
*/
|
||||
function nextId($seq_name, $ondemand = true)
|
||||
public function nextId($seq_name, $ondemand = true)
|
||||
{
|
||||
$seqname = $this->getSequenceName($seq_name);
|
||||
if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) {
|
||||
@ -471,8 +484,7 @@ class DB_sybase extends DB_common
|
||||
$result = $this->query("INSERT INTO $seqname (vapor) VALUES (0)");
|
||||
$this->popErrorHandling();
|
||||
if ($ondemand && DB::isError($result) &&
|
||||
($result->getCode() == DB_ERROR || $result->getCode() == DB_ERROR_NOSUCHTABLE))
|
||||
{
|
||||
($result->getCode() == DB_ERROR || $result->getCode() == DB_ERROR_NOSUCHTABLE)) {
|
||||
$repeat = 1;
|
||||
$result = $this->createSequence($seq_name);
|
||||
if (DB::isError($result)) {
|
||||
@ -502,7 +514,7 @@ class DB_sybase extends DB_common
|
||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||
* DB_sybase::nextID(), DB_sybase::dropSequence()
|
||||
*/
|
||||
function createSequence($seq_name)
|
||||
public function createSequence($seq_name)
|
||||
{
|
||||
return $this->query('CREATE TABLE '
|
||||
. $this->getSequenceName($seq_name)
|
||||
@ -523,7 +535,7 @@ class DB_sybase extends DB_common
|
||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||
* DB_sybase::nextID(), DB_sybase::createSequence()
|
||||
*/
|
||||
function dropSequence($seq_name)
|
||||
public function dropSequence($seq_name)
|
||||
{
|
||||
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
|
||||
}
|
||||
@ -540,7 +552,8 @@ class DB_sybase extends DB_common
|
||||
* @see DB_common::quoteSmart()
|
||||
* @since Method available since release 1.7.8.
|
||||
*/
|
||||
function quoteFloat($float) {
|
||||
public function quoteFloat($float)
|
||||
{
|
||||
return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
|
||||
}
|
||||
|
||||
@ -555,7 +568,7 @@ class DB_sybase extends DB_common
|
||||
* @return int DB_OK on success. A DB_Error object if the driver
|
||||
* doesn't support auto-committing transactions.
|
||||
*/
|
||||
function autoCommit($onoff = false)
|
||||
public function autoCommit($onoff = false)
|
||||
{
|
||||
// XXX if $this->transaction_opcount > 0, we should probably
|
||||
// issue a warning here.
|
||||
@ -571,7 +584,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function commit()
|
||||
public function commit()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) {
|
||||
@ -594,7 +607,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @return int DB_OK on success. A DB_Error object on failure.
|
||||
*/
|
||||
function rollback()
|
||||
public function rollback()
|
||||
{
|
||||
if ($this->transaction_opcount > 0) {
|
||||
if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) {
|
||||
@ -624,7 +637,7 @@ class DB_sybase extends DB_common
|
||||
* @see DB_common::raiseError(),
|
||||
* DB_sybase::errorNative(), DB_sybase::errorCode()
|
||||
*/
|
||||
function sybaseRaiseError($errno = null)
|
||||
public function sybaseRaiseError($errno = null)
|
||||
{
|
||||
$native = $this->errorNative();
|
||||
if ($errno === null) {
|
||||
@ -641,7 +654,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @return string the DBMS' error message
|
||||
*/
|
||||
function errorNative()
|
||||
public function errorNative()
|
||||
{
|
||||
return @sybase_get_last_message();
|
||||
}
|
||||
@ -655,7 +668,7 @@ class DB_sybase extends DB_common
|
||||
* @param string $errormsg error message returned from the database
|
||||
* @return integer an error number from a DB error constant
|
||||
*/
|
||||
function errorCode($errormsg)
|
||||
public function errorCode($errormsg)
|
||||
{
|
||||
static $error_regexps;
|
||||
|
||||
@ -730,7 +743,7 @@ class DB_sybase extends DB_common
|
||||
* @see DB_common::tableInfo()
|
||||
* @since Method available since Release 1.6.0
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
public function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
/*
|
||||
@ -740,8 +753,10 @@ class DB_sybase extends DB_common
|
||||
if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) {
|
||||
return $this->sybaseRaiseError(DB_ERROR_NODBSELECTED);
|
||||
}
|
||||
$id = @sybase_query("SELECT * FROM $result WHERE 1=0",
|
||||
$this->connection);
|
||||
$id = @sybase_query(
|
||||
"SELECT * FROM $result WHERE 1=0",
|
||||
$this->connection
|
||||
);
|
||||
$got_string = true;
|
||||
} elseif (isset($result->result)) {
|
||||
/*
|
||||
@ -791,7 +806,9 @@ class DB_sybase extends DB_common
|
||||
);
|
||||
if ($res[$i]['table']) {
|
||||
$res[$i]['flags'] = $this->_sybase_field_flags(
|
||||
$res[$i]['table'], $res[$i]['name']);
|
||||
$res[$i]['table'],
|
||||
$res[$i]['name']
|
||||
);
|
||||
}
|
||||
if ($mode & DB_TABLEINFO_ORDER) {
|
||||
$res['order'][$res[$i]['name']] = $i;
|
||||
@ -825,7 +842,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _sybase_field_flags($table, $column)
|
||||
public function _sybase_field_flags($table, $column)
|
||||
{
|
||||
static $tableName = null;
|
||||
static $flags = array();
|
||||
@ -868,7 +885,6 @@ class DB_sybase extends DB_common
|
||||
}
|
||||
|
||||
sybase_free_result($res);
|
||||
|
||||
}
|
||||
|
||||
if (array_key_exists($column, $flags)) {
|
||||
@ -892,7 +908,7 @@ class DB_sybase extends DB_common
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _add_flag(&$array, $value)
|
||||
public function _add_flag(&$array, $value)
|
||||
{
|
||||
if (!is_array($array)) {
|
||||
$array = array($value);
|
||||
@ -915,7 +931,7 @@ class DB_sybase extends DB_common
|
||||
* @access protected
|
||||
* @see DB_common::getListOf()
|
||||
*/
|
||||
function getSpecialQuery($type)
|
||||
public function getSpecialQuery($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'tables':
|
||||
@ -929,7 +945,6 @@ class DB_sybase extends DB_common
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -938,5 +953,3 @@ class DB_sybase extends DB_common
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user