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..
|
* Type of data Stored in the object..
|
||||||
@ -61,7 +62,7 @@ class DB_DataObject_Cast {
|
|||||||
* @var string (date|blob|.....?)
|
* @var string (date|blob|.....?)
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $type;
|
public $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data For date representation
|
* Data For date representation
|
||||||
@ -69,9 +70,9 @@ class DB_DataObject_Cast {
|
|||||||
* @var int day/month/year
|
* @var int day/month/year
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $day;
|
public $day;
|
||||||
var $month;
|
public $month;
|
||||||
var $year;
|
public $year;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,7 +82,7 @@ class DB_DataObject_Cast {
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var $value;
|
public $value;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +98,8 @@ class DB_DataObject_Cast {
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function blob($value) {
|
public function blob($value)
|
||||||
|
{
|
||||||
$r = new DB_DataObject_Cast;
|
$r = new DB_DataObject_Cast;
|
||||||
$r->type = 'blob';
|
$r->type = 'blob';
|
||||||
$r->value = $value;
|
$r->value = $value;
|
||||||
@ -117,7 +119,8 @@ class DB_DataObject_Cast {
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function string($value) {
|
public function string($value)
|
||||||
|
{
|
||||||
$r = new DB_DataObject_Cast;
|
$r = new DB_DataObject_Cast;
|
||||||
$r->type = 'string';
|
$r->type = 'string';
|
||||||
$r->value = $value;
|
$r->value = $value;
|
||||||
@ -135,7 +138,7 @@ class DB_DataObject_Cast {
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function sql($value)
|
public function sql($value)
|
||||||
{
|
{
|
||||||
$r = new DB_DataObject_Cast;
|
$r = new DB_DataObject_Cast;
|
||||||
$r->type = 'sql';
|
$r->type = 'sql';
|
||||||
@ -164,7 +167,7 @@ class DB_DataObject_Cast {
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function date()
|
public function date()
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
switch (count($args)) {
|
switch (count($args)) {
|
||||||
@ -216,9 +219,9 @@ class DB_DataObject_Cast {
|
|||||||
* @var int hour/minute/second
|
* @var int hour/minute/second
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $hour;
|
public $hour;
|
||||||
var $minute;
|
public $minute;
|
||||||
var $second;
|
public $second;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -239,13 +242,14 @@ class DB_DataObject_Cast {
|
|||||||
* @author therion 5 at hotmail
|
* @author therion 5 at hotmail
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function dateTime()
|
public function dateTime()
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
switch (count($args)) {
|
switch (count($args)) {
|
||||||
case 0: // no args = now!
|
case 0: // no args = now!
|
||||||
$datetime = date('Y-m-d G:i:s', mktime());
|
$datetime = date('Y-m-d G:i:s', mktime());
|
||||||
|
|
||||||
|
// no break
|
||||||
case 1:
|
case 1:
|
||||||
// continue on from 0 args.
|
// continue on from 0 args.
|
||||||
if (!isset($datetime)) {
|
if (!isset($datetime)) {
|
||||||
@ -280,7 +284,6 @@ class DB_DataObject_Cast {
|
|||||||
$r->minute = $bits[4];
|
$r->minute = $bits[4];
|
||||||
$r->second = $bits[5];
|
$r->second = $bits[5];
|
||||||
return $r;
|
return $r;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -302,13 +305,14 @@ class DB_DataObject_Cast {
|
|||||||
* @access public
|
* @access public
|
||||||
* @author therion 5 at hotmail
|
* @author therion 5 at hotmail
|
||||||
*/
|
*/
|
||||||
function time()
|
public function time()
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
switch (count($args)) {
|
switch (count($args)) {
|
||||||
case 0: // no args = now!
|
case 0: // no args = now!
|
||||||
$time = date('G:i:s', mktime());
|
$time = date('G:i:s', mktime());
|
||||||
|
|
||||||
|
// no break
|
||||||
case 1:
|
case 1:
|
||||||
// continue on from 0 args.
|
// continue on from 0 args.
|
||||||
if (!isset($time)) {
|
if (!isset($time)) {
|
||||||
@ -333,7 +337,6 @@ class DB_DataObject_Cast {
|
|||||||
$r->minute = $bits[1];
|
$r->minute = $bits[1];
|
||||||
$r->second = $bits[2];
|
$r->second = $bits[2];
|
||||||
return $r;
|
return $r;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -350,7 +353,7 @@ class DB_DataObject_Cast {
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function toString($to=false,$db)
|
public function toString($to=false, $db)
|
||||||
{
|
{
|
||||||
// if $this->type is not set, we are in serious trouble!!!!
|
// if $this->type is not set, we are in serious trouble!!!!
|
||||||
// values for to:
|
// values for to:
|
||||||
@ -369,7 +372,7 @@ class DB_DataObject_Cast {
|
|||||||
* @return string
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function toStringFromBlob($to,$db)
|
public function toStringFromBlob($to, $db)
|
||||||
{
|
{
|
||||||
// first weed out invalid casts..
|
// first weed out invalid casts..
|
||||||
// in blobs can only be cast to blobs.!
|
// in blobs can only be cast to blobs.!
|
||||||
@ -408,7 +411,6 @@ class DB_DataObject_Cast {
|
|||||||
default:
|
default:
|
||||||
return PEAR::raiseError("DB_DataObject_Cast cant handle blobs for Database:{$db->dsn['phptype']} Yet");
|
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
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function toStringFromString($to,$db)
|
public function toStringFromString($to, $db)
|
||||||
{
|
{
|
||||||
// first weed out invalid casts..
|
// first weed out invalid casts..
|
||||||
// in blobs can only be cast to blobs.!
|
// in blobs can only be cast to blobs.!
|
||||||
@ -459,7 +461,6 @@ class DB_DataObject_Cast {
|
|||||||
default:
|
default:
|
||||||
return PEAR::raiseError("DB_DataObject_Cast cant handle blobs for Database:{$db->dsn['phptype']} Yet");
|
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
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function toStringFromDate($to,$db)
|
public function toStringFromDate($to, $db)
|
||||||
{
|
{
|
||||||
// first weed out invalid casts..
|
// first weed out invalid casts..
|
||||||
// in blobs can only be cast to blobs.!
|
// in blobs can only be cast to blobs.!
|
||||||
@ -503,7 +504,7 @@ class DB_DataObject_Cast {
|
|||||||
* @author therion 5 at hotmail
|
* @author therion 5 at hotmail
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function toStringFromDateTime($to,$db)
|
public function toStringFromDateTime($to, $db)
|
||||||
{
|
{
|
||||||
// first weed out invalid casts..
|
// first weed out invalid casts..
|
||||||
// in blobs can only be cast to blobs.!
|
// in blobs can only be cast to blobs.!
|
||||||
@ -531,7 +532,7 @@ class DB_DataObject_Cast {
|
|||||||
* @author therion 5 at hotmail
|
* @author therion 5 at hotmail
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function toStringFromTime($to,$db)
|
public function toStringFromTime($to, $db)
|
||||||
{
|
{
|
||||||
// first weed out invalid casts..
|
// first weed out invalid casts..
|
||||||
// in blobs can only be cast to blobs.!
|
// in blobs can only be cast to blobs.!
|
||||||
@ -554,12 +555,8 @@ class DB_DataObject_Cast {
|
|||||||
* @return string
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function toStringFromSql($to,$db)
|
public function toStringFromSql($to, $db)
|
||||||
{
|
{
|
||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,16 +38,15 @@ class DB_DataObject_Error extends PEAR_Error
|
|||||||
*
|
*
|
||||||
* @see PEAR_Error
|
* @see PEAR_Error
|
||||||
*/
|
*/
|
||||||
function DB_DataObject_Error($message = '', $code = DB_ERROR, $mode = PEAR_ERROR_RETURN,
|
public function DB_DataObject_Error(
|
||||||
$level = E_USER_NOTICE)
|
$message = '',
|
||||||
{
|
$code = DB_ERROR,
|
||||||
|
$mode = PEAR_ERROR_RETURN,
|
||||||
|
$level = E_USER_NOTICE
|
||||||
|
) {
|
||||||
$this->PEAR_Error('DB_DataObject Error: ' . $message, $code, $mode, $level);
|
$this->PEAR_Error('DB_DataObject Error: ' . $message, $code, $mode, $level);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// todo : - support code -> message handling, and translated error messages...
|
// todo : - support code -> message handling, and translated error messages...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $tables;
|
public $tables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* associative array table -> array of table row objects
|
* associative array table -> array of table row objects
|
||||||
@ -76,7 +76,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_definitions;
|
public $_definitions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* active table being output
|
* active table being output
|
||||||
@ -84,7 +84,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $table; // active tablename
|
public $table; // active tablename
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* links (generated)
|
* links (generated)
|
||||||
@ -92,7 +92,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_fkeys; // active tablename
|
public $_fkeys; // active tablename
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The 'starter' = call this to start the process
|
* The 'starter' = call this to start the process
|
||||||
@ -100,7 +100,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @access public
|
* @access public
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function start()
|
public function start()
|
||||||
{
|
{
|
||||||
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
||||||
$db_driver = empty($options['db_driver']) ? 'DB' : $options['db_driver'];
|
$db_driver = empty($options['db_driver']) ? 'DB' : $options['db_driver'];
|
||||||
@ -169,7 +169,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @var string outputbuffer for table definitions
|
* @var string outputbuffer for table definitions
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_newConfig;
|
public $_newConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a list of tables;
|
* Build a list of tables;
|
||||||
@ -178,7 +178,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @access private
|
* @access private
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function _createTableList()
|
public function _createTableList()
|
||||||
{
|
{
|
||||||
$this->_connect();
|
$this->_connect();
|
||||||
|
|
||||||
@ -274,7 +274,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
|
|
||||||
// postgres strip the schema bit from the
|
// postgres strip the schema bit from the
|
||||||
if (!empty($strip)) {
|
if (!empty($strip)) {
|
||||||
|
|
||||||
if (!is_string($strip) || preg_match($strip, $table)) {
|
if (!is_string($strip) || preg_match($strip, $table)) {
|
||||||
$bits = explode('.', $table, 2);
|
$bits = explode('.', $table, 2);
|
||||||
$table = $bits[0];
|
$table = $bits[0];
|
||||||
@ -289,12 +288,10 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
$__DB->quoteIdentifier($table) : $table;
|
$__DB->quoteIdentifier($table) : $table;
|
||||||
|
|
||||||
if (!$is_MDB2) {
|
if (!$is_MDB2) {
|
||||||
|
|
||||||
$defs = $__DB->tableInfo($quotedTable);
|
$defs = $__DB->tableInfo($quotedTable);
|
||||||
} else {
|
} else {
|
||||||
$defs = $__DB->reverse->tableInfo($quotedTable);
|
$defs = $__DB->reverse->tableInfo($quotedTable);
|
||||||
// rename the length value, so it matches db's return.
|
// rename the length value, so it matches db's return.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_object($defs) && is_a($defs, 'PEAR_Error')) {
|
if (is_object($defs) && is_a($defs, 'PEAR_Error')) {
|
||||||
@ -316,12 +313,9 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
$def['len'] = $def['length'];
|
$def['len'] = $def['length'];
|
||||||
}
|
}
|
||||||
$this->_definitions[$table][] = (object) $def;
|
$this->_definitions[$table][] = (object) $def;
|
||||||
|
|
||||||
}
|
}
|
||||||
// we find a matching table, just store it into a temporary array
|
// we find a matching table, just store it into a temporary array
|
||||||
$tmp_table[] = $table;
|
$tmp_table[] = $table;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// the temporary table array is now the right one (tables names matching
|
// the temporary table array is now the right one (tables names matching
|
||||||
// with regex expressions have been removed)
|
// with regex expressions have been removed)
|
||||||
@ -338,7 +332,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @access private
|
* @access private
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function generateDefinitions()
|
public function generateDefinitions()
|
||||||
{
|
{
|
||||||
$this->debug("Generating Definitions file: ");
|
$this->debug("Generating Definitions file: ");
|
||||||
if (!$this->tables) {
|
if (!$this->tables) {
|
||||||
@ -382,8 +376,10 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
if (!$fh) {
|
if (!$fh) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Failed to create temporary file: $tmpname\n".
|
"Failed to create temporary file: $tmpname\n".
|
||||||
"make sure session.save_path is set and is writable\n"
|
"make sure session.save_path is set and is writable\n",
|
||||||
,null, PEAR_ERROR_DIE);
|
null,
|
||||||
|
PEAR_ERROR_DIE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
fwrite($fh, $this->_newConfig);
|
fwrite($fh, $this->_newConfig);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
@ -409,7 +405,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @author Pascal Sch<EFBFBD>ni
|
* @author Pascal Sch<EFBFBD>ni
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function _createForiegnKeys()
|
public function _createForiegnKeys()
|
||||||
{
|
{
|
||||||
$options = PEAR::getStaticProperty('DB_DataObject', 'options');
|
$options = PEAR::getStaticProperty('DB_DataObject', 'options');
|
||||||
if (empty($options['generate_links'])) {
|
if (empty($options['generate_links'])) {
|
||||||
@ -449,7 +445,8 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
preg_match(
|
preg_match(
|
||||||
"/FOREIGN KEY \((\w*)\) REFERENCES (\w*)\((\w*)\)/i",
|
"/FOREIGN KEY \((\w*)\) REFERENCES (\w*)\((\w*)\)/i",
|
||||||
$row['condef'],
|
$row['condef'],
|
||||||
$treffer);
|
$treffer
|
||||||
|
);
|
||||||
if (!count($treffer)) {
|
if (!count($treffer)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -479,7 +476,8 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
"/FOREIGN KEY \(`(\w*)`\) REFERENCES `(\w*)` \(`(\w*)`\)/i",
|
"/FOREIGN KEY \(`(\w*)`\) REFERENCES `(\w*)` \(`(\w*)`\)/i",
|
||||||
$text[1],
|
$text[1],
|
||||||
$treffer,
|
$treffer,
|
||||||
PREG_SET_ORDER);
|
PREG_SET_ORDER
|
||||||
|
);
|
||||||
|
|
||||||
if (!count($treffer)) {
|
if (!count($treffer)) {
|
||||||
continue;
|
continue;
|
||||||
@ -487,18 +485,12 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
foreach ($treffer as $i=> $tref) {
|
foreach ($treffer as $i=> $tref) {
|
||||||
$fk[$this->table][$tref[1]] = $tref[2] . ":" . $tref[3];
|
$fk[$this->table][$tref[1]] = $tref[2] . ":" . $tref[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->_fkeys = $fk;
|
$this->_fkeys = $fk;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -509,7 +501,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
*
|
*
|
||||||
* @author Pascal Sch<EFBFBD>ni
|
* @author Pascal Sch<EFBFBD>ni
|
||||||
*/
|
*/
|
||||||
function generateForeignKeys()
|
public function generateForeignKeys()
|
||||||
{
|
{
|
||||||
$options = PEAR::getStaticProperty('DB_DataObject', 'options');
|
$options = PEAR::getStaticProperty('DB_DataObject', 'options');
|
||||||
if (empty($options['generate_links'])) {
|
if (empty($options['generate_links'])) {
|
||||||
@ -560,8 +552,10 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
if (!$fh) {
|
if (!$fh) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Failed to create temporary file: $tmpname\n".
|
"Failed to create temporary file: $tmpname\n".
|
||||||
"make sure session.save_path is set and is writable\n"
|
"make sure session.save_path is set and is writable\n",
|
||||||
,null, PEAR_ERROR_DIE);
|
null,
|
||||||
|
PEAR_ERROR_DIE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
fwrite($fh, $links_ini);
|
fwrite($fh, $links_ini);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
@ -581,7 +575,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @access private
|
* @access private
|
||||||
* @return tabledef and keys array.
|
* @return tabledef and keys array.
|
||||||
*/
|
*/
|
||||||
function _generateDefinitionsTable()
|
public function _generateDefinitionsTable()
|
||||||
{
|
{
|
||||||
global $_DB_DATAOBJECT;
|
global $_DB_DATAOBJECT;
|
||||||
$options = PEAR::getStaticProperty('DB_DataObject', 'options');
|
$options = PEAR::getStaticProperty('DB_DataObject', 'options');
|
||||||
@ -608,7 +602,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
|
|
||||||
|
|
||||||
foreach ($defs as $t) {
|
foreach ($defs as $t) {
|
||||||
|
|
||||||
$n=0;
|
$n=0;
|
||||||
$write_ini = true;
|
$write_ini = true;
|
||||||
|
|
||||||
@ -783,7 +776,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
$m = array();
|
$m = array();
|
||||||
if (preg_match('/(auto_increment|nextval\(([^)]*))/i', rawurldecode($t->flags), $m)
|
if (preg_match('/(auto_increment|nextval\(([^)]*))/i', rawurldecode($t->flags), $m)
|
||||||
|| (isset($t->autoincrement) && ($t->autoincrement === true))) {
|
|| (isset($t->autoincrement) && ($t->autoincrement === true))) {
|
||||||
|
|
||||||
$sn = 'N';
|
$sn = 'N';
|
||||||
if ($DB->phptype == 'pgsql' && !empty($m[2])) {
|
if ($DB->phptype == 'pgsql' && !empty($m[2])) {
|
||||||
$sn = preg_replace('/[("]+/', '', $m[2]);
|
$sn = preg_replace('/[("]+/', '', $m[2]);
|
||||||
@ -794,7 +786,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
$keys_out_primary .= "{$t->name} = $sn\n";
|
$keys_out_primary .= "{$t->name} = $sn\n";
|
||||||
}
|
}
|
||||||
$ret_keys_primary[$t->name] = $sn;
|
$ret_keys_primary[$t->name] = $sn;
|
||||||
|
|
||||||
} elseif ($secondary_key_match && preg_match('/('.$secondary_key_match.')/i', $t->flags)) {
|
} elseif ($secondary_key_match && preg_match('/('.$secondary_key_match.')/i', $t->flags)) {
|
||||||
// keys.. = 1
|
// keys.. = 1
|
||||||
$key_type = 'K';
|
$key_type = 'K';
|
||||||
@ -807,8 +798,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
}
|
}
|
||||||
$ret_keys_secondary[$t->name] = $key_type;
|
$ret_keys_secondary[$t->name] = $key_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_newConfig .= $keys_out . (empty($keys_out_primary) ? $keys_out_secondary : $keys_out_primary);
|
$this->_newConfig .= $keys_out . (empty($keys_out_primary) ? $keys_out_secondary : $keys_out_primary);
|
||||||
@ -819,8 +808,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -831,7 +818,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function getClassNameFromTableName($table)
|
public function getClassNameFromTableName($table)
|
||||||
{
|
{
|
||||||
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
||||||
$class_prefix = empty($options['class_prefix']) ? '' : $options['class_prefix'];
|
$class_prefix = empty($options['class_prefix']) ? '' : $options['class_prefix'];
|
||||||
@ -847,7 +834,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function getFileNameFromTableName($table)
|
public function getFileNameFromTableName($table)
|
||||||
{
|
{
|
||||||
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
||||||
$base = $options['class_location'];
|
$base = $options['class_location'];
|
||||||
@ -859,13 +846,14 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
System::mkdir(array('-p',$base));
|
System::mkdir(array('-p',$base));
|
||||||
}
|
}
|
||||||
if (strpos($options['class_location'], '%s') !== false) {
|
if (strpos($options['class_location'], '%s') !== false) {
|
||||||
$outfilename = sprintf($options['class_location'],
|
$outfilename = sprintf(
|
||||||
preg_replace('/[^A-Z0-9]/i','_',ucfirst($this->table)));
|
$options['class_location'],
|
||||||
|
preg_replace('/[^A-Z0-9]/i', '_', ucfirst($this->table))
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$outfilename = "{$base}/".preg_replace('/[^A-Z0-9]/i', '_', ucfirst($this->table)).".php";
|
$outfilename = "{$base}/".preg_replace('/[^A-Z0-9]/i', '_', ucfirst($this->table)).".php";
|
||||||
}
|
}
|
||||||
return $outfilename;
|
return $outfilename;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -877,7 +865,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function getMethodNameFromColumnName($col)
|
public function getMethodNameFromColumnName($col)
|
||||||
{
|
{
|
||||||
return ucfirst($col);
|
return ucfirst($col);
|
||||||
}
|
}
|
||||||
@ -889,7 +877,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* building the class files
|
* building the class files
|
||||||
* for each of the tables output a file!
|
* for each of the tables output a file!
|
||||||
*/
|
*/
|
||||||
function generateClasses()
|
public function generateClasses()
|
||||||
{
|
{
|
||||||
//echo "Generating Class files: \n";
|
//echo "Generating Class files: \n";
|
||||||
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
||||||
@ -918,8 +906,10 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
if (!$fh) {
|
if (!$fh) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"Failed to create temporary file: $tmpname\n".
|
"Failed to create temporary file: $tmpname\n".
|
||||||
"make sure session.save_path is set and is writable\n"
|
"make sure session.save_path is set and is writable\n",
|
||||||
,null, PEAR_ERROR_DIE);
|
null,
|
||||||
|
PEAR_ERROR_DIE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
fputs($fh, $out);
|
fputs($fh, $out);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
@ -942,7 +932,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_extends = 'DB_DataObject';
|
public $_extends = 'DB_DataObject';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* line to use for require('DB/DataObject.php');
|
* line to use for require('DB/DataObject.php');
|
||||||
@ -950,7 +940,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_extendsFile = "DB/DataObject.php";
|
public $_extendsFile = "DB/DataObject.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class being generated
|
* class being generated
|
||||||
@ -958,7 +948,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_className;
|
public $_className;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The table class geneation part - single file.
|
* The table class geneation part - single file.
|
||||||
@ -966,7 +956,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @access private
|
* @access private
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function _generateClassTable($input = '')
|
public function _generateClassTable($input = '')
|
||||||
{
|
{
|
||||||
// title = expand me!
|
// title = expand me!
|
||||||
$foot = "";
|
$foot = "";
|
||||||
@ -1105,7 +1095,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
// but it helps on older projects.
|
// but it helps on older projects.
|
||||||
$def = $this->_generateDefinitionsTable(); // simplify this!?
|
$def = $this->_generateDefinitionsTable(); // simplify this!?
|
||||||
$body .= $this->_generateDefaultsFunction($this->table, $def['table']);
|
$body .= $this->_generateDefaultsFunction($this->table, $def['table']);
|
||||||
|
|
||||||
}
|
}
|
||||||
$body .= $this->derivedHookFunctions($input);
|
$body .= $this->derivedHookFunctions($input);
|
||||||
|
|
||||||
@ -1161,18 +1150,23 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
$input = preg_replace(
|
$input = preg_replace(
|
||||||
'/(\n|\r\n)class\s*[a-z0-9_]+\s*extends\s*' .$class_rewrite . '\s*(\n|\r\n)\{(\n|\r\n)/si',
|
'/(\n|\r\n)class\s*[a-z0-9_]+\s*extends\s*' .$class_rewrite . '\s*(\n|\r\n)\{(\n|\r\n)/si',
|
||||||
"\nclass {$this->classname} extends {$this->_extends} \n{\n",
|
"\nclass {$this->classname} extends {$this->_extends} \n{\n",
|
||||||
$input);
|
$input
|
||||||
|
);
|
||||||
|
|
||||||
$ret = preg_replace(
|
$ret = preg_replace(
|
||||||
'/(\n|\r\n)\s*###START_AUTOCODE(\n|\r\n).*(\n|\r\n)\s*###END_AUTOCODE(\n|\r\n)/s',
|
'/(\n|\r\n)\s*###START_AUTOCODE(\n|\r\n).*(\n|\r\n)\s*###END_AUTOCODE(\n|\r\n)/s',
|
||||||
$body,$input);
|
$body,
|
||||||
|
$input
|
||||||
|
);
|
||||||
|
|
||||||
if (!strlen($ret)) {
|
if (!strlen($ret)) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
"PREG_REPLACE failed to replace body, - you probably need to set these in your php.ini\n".
|
"PREG_REPLACE failed to replace body, - you probably need to set these in your php.ini\n".
|
||||||
"pcre.backtrack_limit=1000000\n".
|
"pcre.backtrack_limit=1000000\n".
|
||||||
"pcre.recursion_limit=1000000\n"
|
"pcre.recursion_limit=1000000\n",
|
||||||
,null, PEAR_ERROR_DIE);
|
null,
|
||||||
|
PEAR_ERROR_DIE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
@ -1188,7 +1182,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string added to class eg. functions.
|
* @return string added to class eg. functions.
|
||||||
*/
|
*/
|
||||||
function derivedHookFunctions($input = "")
|
public function derivedHookFunctions($input = "")
|
||||||
{
|
{
|
||||||
// This is so derived generator classes can generate functions
|
// This is so derived generator classes can generate functions
|
||||||
// It MUST NOT be changed here!!!
|
// It MUST NOT be changed here!!!
|
||||||
@ -1205,7 +1199,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string added to class eg. functions.
|
* @return string added to class eg. functions.
|
||||||
*/
|
*/
|
||||||
function derivedHookVar(&$t,$padding)
|
public function derivedHookVar(&$t, $padding)
|
||||||
{
|
{
|
||||||
// This is so derived generator classes can generate variabels
|
// This is so derived generator classes can generate variabels
|
||||||
// It MUST NOT be changed here!!!
|
// It MUST NOT be changed here!!!
|
||||||
@ -1220,7 +1214,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string added to class eg. functions.
|
* @return string added to class eg. functions.
|
||||||
*/
|
*/
|
||||||
function derivedHookPostVar($t)
|
public function derivedHookPostVar($t)
|
||||||
{
|
{
|
||||||
// This is so derived generator classes can generate variabels
|
// This is so derived generator classes can generate variabels
|
||||||
// It MUST NOT be changed here!!!
|
// It MUST NOT be changed here!!!
|
||||||
@ -1233,7 +1227,8 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string added to class eg. functions.
|
* @return string added to class eg. functions.
|
||||||
*/
|
*/
|
||||||
function derivedHookPageLevelDocBlock() {
|
public function derivedHookPageLevelDocBlock()
|
||||||
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1245,7 +1240,8 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string added to class eg. functions.
|
* @return string added to class eg. functions.
|
||||||
*/
|
*/
|
||||||
function derivedHookExtendsDocBlock() {
|
public function derivedHookExtendsDocBlock()
|
||||||
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1257,7 +1253,8 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string added to class eg. functions.
|
* @return string added to class eg. functions.
|
||||||
*/
|
*/
|
||||||
function derivedHookClassDocBlock() {
|
public function derivedHookClassDocBlock()
|
||||||
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1276,9 +1273,8 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @return object Instance of class. or PEAR Error
|
* @return object Instance of class. or PEAR Error
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function getProxyFull($database,$table)
|
public function getProxyFull($database, $table)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($err = $this->fillTableSchema($database, $table)) {
|
if ($err = $this->fillTableSchema($database, $table)) {
|
||||||
return $err;
|
return $err;
|
||||||
}
|
}
|
||||||
@ -1296,7 +1292,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
//echo $out;
|
//echo $out;
|
||||||
eval('?>'.$out);
|
eval('?>'.$out);
|
||||||
return new $classname;
|
return new $classname;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1310,7 +1305,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @return none | PEAR::error()
|
* @return none | PEAR::error()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function fillTableSchema($database,$table)
|
public function fillTableSchema($database, $table)
|
||||||
{
|
{
|
||||||
global $_DB_DATAOBJECT;
|
global $_DB_DATAOBJECT;
|
||||||
// a little bit of sanity testing.
|
// a little bit of sanity testing.
|
||||||
@ -1390,7 +1385,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
$_DB_DATAOBJECT['INI'][$database][$table] = $ret['table'];
|
$_DB_DATAOBJECT['INI'][$database][$table] = $ret['table'];
|
||||||
$_DB_DATAOBJECT['INI'][$database][$table.'__keys'] = $ret['keys'];
|
$_DB_DATAOBJECT['INI'][$database][$table.'__keys'] = $ret['keys'];
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1400,9 +1394,8 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @return string
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _generateGetters($input)
|
public function _generateGetters($input)
|
||||||
{
|
{
|
||||||
|
|
||||||
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
||||||
$getters = '';
|
$getters = '';
|
||||||
|
|
||||||
@ -1451,9 +1444,8 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @return string
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _generateLinkMethods($input)
|
public function _generateLinkMethods($input)
|
||||||
{
|
{
|
||||||
|
|
||||||
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
||||||
$setters = '';
|
$setters = '';
|
||||||
|
|
||||||
@ -1520,9 +1512,8 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @return string
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _generateSetters($input)
|
public function _generateSetters($input)
|
||||||
{
|
{
|
||||||
|
|
||||||
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
|
||||||
$setters = '';
|
$setters = '';
|
||||||
|
|
||||||
@ -1570,7 +1561,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @return string
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _generateTableFunction($def)
|
public function _generateTableFunction($def)
|
||||||
{
|
{
|
||||||
$defines = explode(',', 'INT,STR,DATE,TIME,BOOL,TXT,BLOB,NOTNULL,MYSQLTIMESTAMP');
|
$defines = explode(',', 'INT,STR,DATE,TIME,BOOL,TXT,BLOB,NOTNULL,MYSQLTIMESTAMP');
|
||||||
|
|
||||||
@ -1594,9 +1585,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
}
|
}
|
||||||
return $ret . " );\n" .
|
return $ret . " );\n" .
|
||||||
" }\n";
|
" }\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Generate keys Function - used generator_no_ini is set.
|
* Generate keys Function - used generator_no_ini is set.
|
||||||
@ -1605,9 +1593,8 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @return string
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _generateKeysFunction($def)
|
public function _generateKeysFunction($def)
|
||||||
{
|
{
|
||||||
|
|
||||||
$ret = "\n" .
|
$ret = "\n" .
|
||||||
" function keys()\n" .
|
" function keys()\n" .
|
||||||
" {\n" .
|
" {\n" .
|
||||||
@ -1620,9 +1607,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
$ret = preg_replace('#, $#', '', $ret);
|
$ret = preg_replace('#, $#', '', $ret);
|
||||||
return $ret . ");\n" .
|
return $ret . ");\n" .
|
||||||
" }\n";
|
" }\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Generate sequenceKey Function - used generator_no_ini is set.
|
* Generate sequenceKey Function - used generator_no_ini is set.
|
||||||
@ -1631,7 +1615,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @return string
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _generateSequenceKeyFunction($def)
|
public function _generateSequenceKeyFunction($def)
|
||||||
{
|
{
|
||||||
|
|
||||||
//print_r($def);
|
//print_r($def);
|
||||||
@ -1700,7 +1684,6 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
$ret = preg_replace('#, $#', '', $ret);
|
$ret = preg_replace('#, $#', '', $ret);
|
||||||
return $ret . ");\n" .
|
return $ret . ");\n" .
|
||||||
" }\n";
|
" }\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Generate defaults Function - used generator_add_defaults or generator_no_ini is set.
|
* Generate defaults Function - used generator_add_defaults or generator_no_ini is set.
|
||||||
@ -1711,7 +1694,7 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
* @return string
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function _generateDefaultsFunction($table,$defs)
|
public function _generateDefaultsFunction($table, $defs)
|
||||||
{
|
{
|
||||||
$__DB= &$GLOBALS['_DB_DATAOBJECT']['CONNECTIONS'][$this->_database_dsn_md5];
|
$__DB= &$GLOBALS['_DB_DATAOBJECT']['CONNECTIONS'][$this->_database_dsn_md5];
|
||||||
if (!in_array($__DB->phptype, array('mysql','mysqli'))) {
|
if (!in_array($__DB->phptype, array('mysql','mysqli'))) {
|
||||||
@ -1772,14 +1755,5 @@ class DB_DataObject_Generator extends DB_DataObject
|
|||||||
}
|
}
|
||||||
return $ret . " );\n" .
|
return $ret . " );\n" .
|
||||||
" }\n";
|
" }\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,39 +41,39 @@ class DB_DataObject_Links
|
|||||||
/**
|
/**
|
||||||
* @property {DB_DataObject} do DataObject to apply this to.
|
* @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)
|
* @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 {String|Boolean} scanf use part of column name as resulting
|
||||||
* property name. (default false)
|
* property name. (default false)
|
||||||
*/
|
*/
|
||||||
var $scanf = false;
|
public $scanf = false;
|
||||||
/**
|
/**
|
||||||
* @property {String|Boolean} printf use column name as sprintf for resulting property name..
|
* @property {String|Boolean} printf use column name as sprintf for resulting property name..
|
||||||
* (default %s_link if apply is true, otherwise it is %s)
|
* (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
|
* @property {Boolean} cached cache the result, so future queries will use cache rather
|
||||||
* than running the expensive sql query.
|
* than running the expensive sql query.
|
||||||
*/
|
*/
|
||||||
var $cached = false;
|
public $cached = false;
|
||||||
/**
|
/**
|
||||||
* @property {Boolean} apply apply the result to this object, (default true)
|
* @property {Boolean} apply apply the result to this object, (default true)
|
||||||
*/
|
*/
|
||||||
var $apply = true;
|
public $apply = true;
|
||||||
|
|
||||||
|
|
||||||
//------------------------- RETURN ------------------------------------
|
//------------------------- RETURN ------------------------------------
|
||||||
/**
|
/**
|
||||||
* @property {Array} links key value associative array of links.
|
* @property {Array} links key value associative array of links.
|
||||||
*/
|
*/
|
||||||
var $links;
|
public $links;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,7 +83,7 @@ class DB_DataObject_Links
|
|||||||
* @param {Array} cfg Configuration (basically properties of this object)
|
* @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!!!?
|
// check if do is set!!!?
|
||||||
$this->do = $do;
|
$this->do = $do;
|
||||||
@ -91,8 +91,6 @@ class DB_DataObject_Links
|
|||||||
foreach ($cfg as $k=>$v) {
|
foreach ($cfg as $k=>$v) {
|
||||||
$this->$k = $v;
|
$this->$k = $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,16 +108,13 @@ class DB_DataObject_Links
|
|||||||
* @access public
|
* @access public
|
||||||
* @return mixed object on success false on failure or '0' when not linked
|
* @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();
|
static $cache = array();
|
||||||
|
|
||||||
// GUESS THE LINKED TABLE.. (if found - recursevly call self)
|
// GUESS THE LINKED TABLE.. (if found - recursevly call self)
|
||||||
|
|
||||||
if ($table == false) {
|
if ($table == false) {
|
||||||
|
|
||||||
|
|
||||||
$info = $this->linkInfo($field);
|
$info = $this->linkInfo($field);
|
||||||
|
|
||||||
if ($info) {
|
if ($info) {
|
||||||
@ -133,9 +128,6 @@ class DB_DataObject_Links
|
|||||||
}
|
}
|
||||||
$table = substr($field, 0, $p);
|
$table = substr($field, 0, $p);
|
||||||
return $this->getLink($field, $table);
|
return $this->getLink($field, $table);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$tn = is_string($table) ? $table : $table->tableName();
|
$tn = is_string($table) ? $table : $table->tableName();
|
||||||
@ -158,19 +150,20 @@ class DB_DataObject_Links
|
|||||||
return $cache[$tn.':'. $link .':'. $this->do->$field];
|
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(
|
$this->do->raiseError(
|
||||||
"getLink:Could not find class for row $field, table $tn",
|
"getLink:Could not find class for row $field, table $tn",
|
||||||
DB_DATAOBJECT_ERROR_INVALIDCONFIG);
|
DB_DATAOBJECT_ERROR_INVALIDCONFIG
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// -1 or 0 -- no referenced record..
|
// -1 or 0 -- no referenced record..
|
||||||
|
|
||||||
$ret = false;
|
$ret = false;
|
||||||
if ($link) {
|
if ($link) {
|
||||||
|
|
||||||
if ($obj->get($link, $this->do->$field)) {
|
if ($obj->get($link, $this->do->$field)) {
|
||||||
$ret = $obj;
|
$ret = $obj;
|
||||||
}
|
}
|
||||||
@ -179,13 +172,11 @@ class DB_DataObject_Links
|
|||||||
// this really only happens when no link config is set (old BC stuff)
|
// this really only happens when no link config is set (old BC stuff)
|
||||||
} elseif ($obj->get($this->do->$field)) {
|
} elseif ($obj->get($this->do->$field)) {
|
||||||
$ret= $obj;
|
$ret= $obj;
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($this->cached) {
|
if ($this->cached) {
|
||||||
$cache[$tn.':'. $link .':'. $this->do->$field] = $ret;
|
$cache[$tn.':'. $link .':'. $this->do->$field] = $ret;
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* get link information for a field or field specification
|
* 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 (is_array($field)) {
|
||||||
if (count($field) == 3) {
|
if (count($field) == 3) {
|
||||||
// array with 3 args:
|
// array with 3 args:
|
||||||
@ -213,7 +203,6 @@ class DB_DataObject_Links
|
|||||||
$field[2],
|
$field[2],
|
||||||
$field[0]
|
$field[0]
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
list($table, $link) = explode(':', $field[1]);
|
list($table, $link) = explode(':', $field[1]);
|
||||||
|
|
||||||
@ -222,20 +211,17 @@ class DB_DataObject_Links
|
|||||||
$link,
|
$link,
|
||||||
$field[0]
|
$field[0]
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
// work out the link.. (classic way)
|
// work out the link.. (classic way)
|
||||||
|
|
||||||
$links = $this->do->links();
|
$links = $this->do->links();
|
||||||
|
|
||||||
if (empty($links) || !is_array($links)) {
|
if (empty($links) || !is_array($links)) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isset($links[$field])) {
|
if (!isset($links[$field])) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
list($table, $link) = explode(':', $links[$field]);
|
list($table, $link) = explode(':', $links[$field]);
|
||||||
@ -251,10 +237,6 @@ class DB_DataObject_Links
|
|||||||
$link,
|
$link,
|
||||||
$field
|
$field
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -277,14 +259,15 @@ class DB_DataObject_Links
|
|||||||
* @return mixed true of false on set, the object on getter.
|
* @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);
|
$info = $this->linkInfo($field);
|
||||||
|
|
||||||
if (!$info) {
|
if (!$info) {
|
||||||
$this->do->raiseError(
|
$this->do->raiseError(
|
||||||
"getLink:Could not find link for row $field",
|
"getLink:Could not find link for row $field",
|
||||||
DB_DATAOBJECT_ERROR_INVALIDCONFIG);
|
DB_DATAOBJECT_ERROR_INVALIDCONFIG
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$field = $info[2];
|
$field = $info[2];
|
||||||
@ -299,16 +282,13 @@ class DB_DataObject_Links
|
|||||||
$ret = $this->getLink($field);
|
$ret = $this->getLink($field);
|
||||||
// nothing linked -- return new object..
|
// nothing linked -- return new object..
|
||||||
return ($ret === 0) ? $info[0] : $ret;
|
return ($ret === 0) ? $info[0] : $ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
$assign = is_array($args) ? $args[0] : $args;
|
$assign = is_array($args) ? $args[0] : $args;
|
||||||
|
|
||||||
// otherwise it's a set call..
|
// 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 (is_numeric($assign) && is_integer($assign * 1)) {
|
||||||
if ($assign > 0) {
|
if ($assign > 0) {
|
||||||
|
|
||||||
if (!$info) {
|
if (!$info) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -316,7 +296,6 @@ class DB_DataObject_Links
|
|||||||
if (!$info[0]->get($info[1], $assign)) {
|
if (!$info[0]->get($info[1], $assign)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->do->$field = $assign ;
|
$this->do->$field = $assign ;
|
||||||
@ -330,8 +309,6 @@ class DB_DataObject_Links
|
|||||||
|
|
||||||
$this->do->$field = $assign->{$info[1]};
|
$this->do->$field = $assign->{$info[1]};
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* load related objects
|
* load related objects
|
||||||
@ -351,7 +328,7 @@ class DB_DataObject_Links
|
|||||||
* @return boolean , true on success
|
* @return boolean , true on success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function applyLinks($format = '_%s')
|
public function applyLinks($format = '_%s')
|
||||||
{
|
{
|
||||||
|
|
||||||
// get table will load the options.
|
// get table will load the options.
|
||||||
@ -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();
|
$ret = array();
|
||||||
if (!$table) {
|
if (!$table) {
|
||||||
|
|
||||||
|
|
||||||
$links = $this->do->links();
|
$links = $this->do->links();
|
||||||
|
|
||||||
if (is_array($links)) {
|
if (is_array($links)) {
|
||||||
@ -455,8 +429,6 @@ class DB_DataObject_Links
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
return $this->getLinkArray($field, substr($field, 0, $p));
|
return $this->getLinkArray($field, substr($field, 0, $p));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$c = $this->do->factory($table);
|
$c = $this->do->factory($table);
|
||||||
@ -478,8 +450,5 @@ class DB_DataObject_Links
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
return $c->fetchAll($fkey, $fval, $fmethod);
|
return $c->fetchAll($fkey, $fval, $fmethod);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -60,4 +60,3 @@ DB_DataObject::debugLevel(isset($options['debug']) ? $options['debug'] : 1);
|
|||||||
|
|
||||||
$generator = new DB_DataObject_Generator;
|
$generator = new DB_DataObject_Generator;
|
||||||
$generator->start();
|
$generator->start();
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class DB_common extends PEAR
|
|||||||
* The current default fetch mode
|
* The current default fetch mode
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
var $fetchmode = DB_FETCHMODE_ORDERED;
|
public $fetchmode = DB_FETCHMODE_ORDERED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the class into which results should be fetched when
|
* The name of the class into which results should be fetched when
|
||||||
@ -61,20 +61,20 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $fetchmode_object_class = 'stdClass';
|
public $fetchmode_object_class = 'stdClass';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Was a connection present when the object was serialized()?
|
* Was a connection present when the object was serialized()?
|
||||||
* @var bool
|
* @var bool
|
||||||
* @see DB_common::__sleep(), DB_common::__wake()
|
* @see DB_common::__sleep(), DB_common::__wake()
|
||||||
*/
|
*/
|
||||||
var $was_connected = null;
|
public $was_connected = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The most recently executed query
|
* The most recently executed query
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $last_query = '';
|
public $last_query = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run-time configuration options
|
* Run-time configuration options
|
||||||
@ -85,7 +85,7 @@ class DB_common extends PEAR
|
|||||||
* @var array
|
* @var array
|
||||||
* @see DB_common::setOption()
|
* @see DB_common::setOption()
|
||||||
*/
|
*/
|
||||||
var $options = array(
|
public $options = array(
|
||||||
'result_buffering' => 500,
|
'result_buffering' => 500,
|
||||||
'persistent' => false,
|
'persistent' => false,
|
||||||
'ssl' => false,
|
'ssl' => false,
|
||||||
@ -101,32 +101,32 @@ class DB_common extends PEAR
|
|||||||
* @var array
|
* @var array
|
||||||
* @since Property available since Release 1.7.0
|
* @since Property available since Release 1.7.0
|
||||||
*/
|
*/
|
||||||
var $last_parameters = array();
|
public $last_parameters = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The elements from each prepared statement
|
* The elements from each prepared statement
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $prepare_tokens = array();
|
public $prepare_tokens = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The data types of the various elements in each prepared statement
|
* The data types of the various elements in each prepared statement
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $prepare_types = array();
|
public $prepare_types = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The prepared queries
|
* The prepared queries
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $prepared_queries = array();
|
public $prepared_queries = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag indicating that the last query was a manipulation query.
|
* Flag indicating that the last query was a manipulation query.
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
var $_last_query_manip = false;
|
public $_last_query_manip = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag indicating that the next query <em>must</em> be a manipulation
|
* Flag indicating that the next query <em>must</em> be a manipulation
|
||||||
@ -134,7 +134,7 @@ class DB_common extends PEAR
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
var $_next_query_manip = false;
|
public $_next_query_manip = false;
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -145,7 +145,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->PEAR('DB_Error');
|
$this->PEAR('DB_Error');
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @return array the array of properties names that should be saved
|
* @return array the array of properties names that should be saved
|
||||||
*/
|
*/
|
||||||
function __sleep()
|
public function __sleep()
|
||||||
{
|
{
|
||||||
if ($this->connection) {
|
if ($this->connection) {
|
||||||
// Don't disconnect(), people use serialize() for many reasons
|
// Don't disconnect(), people use serialize() for many reasons
|
||||||
@ -201,7 +201,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __wakeup()
|
public function __wakeup()
|
||||||
{
|
{
|
||||||
if ($this->was_connected) {
|
if ($this->was_connected) {
|
||||||
$this->connect($this->dsn, $this->options['persistent']);
|
$this->connect($this->dsn, $this->options['persistent']);
|
||||||
@ -218,7 +218,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @since Method available since Release 1.7.0
|
* @since Method available since Release 1.7.0
|
||||||
*/
|
*/
|
||||||
function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$info = strtolower(get_class($this));
|
$info = strtolower(get_class($this));
|
||||||
$info .= ': (phptype=' . $this->phptype .
|
$info .= ': (phptype=' . $this->phptype .
|
||||||
@ -240,7 +240,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @deprecated Method deprecated in Release 1.7.0
|
* @deprecated Method deprecated in Release 1.7.0
|
||||||
*/
|
*/
|
||||||
function toString()
|
public function toString()
|
||||||
{
|
{
|
||||||
return $this->__toString();
|
return $this->__toString();
|
||||||
}
|
}
|
||||||
@ -259,7 +259,7 @@ class DB_common extends PEAR
|
|||||||
* @see DB_common::quoteSmart(), DB_common::escapeSimple()
|
* @see DB_common::quoteSmart(), DB_common::escapeSimple()
|
||||||
* @deprecated Method deprecated some time before Release 1.2
|
* @deprecated Method deprecated some time before Release 1.2
|
||||||
*/
|
*/
|
||||||
function quoteString($string)
|
public function quoteString($string)
|
||||||
{
|
{
|
||||||
$string = $this->quoteSmart($string);
|
$string = $this->quoteSmart($string);
|
||||||
if ($string{0} == "'") {
|
if ($string{0} == "'") {
|
||||||
@ -282,7 +282,7 @@ class DB_common extends PEAR
|
|||||||
* @see DB_common::quoteSmart(), DB_common::escapeSimple()
|
* @see DB_common::quoteSmart(), DB_common::escapeSimple()
|
||||||
* @deprecated Deprecated in release 1.6.0
|
* @deprecated Deprecated in release 1.6.0
|
||||||
*/
|
*/
|
||||||
function quote($string = null)
|
public function quote($string = null)
|
||||||
{
|
{
|
||||||
return $this->quoteSmart($string);
|
return $this->quoteSmart($string);
|
||||||
}
|
}
|
||||||
@ -327,7 +327,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function quoteIdentifier($str)
|
public function quoteIdentifier($str)
|
||||||
{
|
{
|
||||||
return '"' . str_replace('"', '""', $str) . '"';
|
return '"' . str_replace('"', '""', $str) . '"';
|
||||||
}
|
}
|
||||||
@ -436,7 +436,7 @@ class DB_common extends PEAR
|
|||||||
* @see DB_common::escapeSimple()
|
* @see DB_common::escapeSimple()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function quoteSmart($in)
|
public function quoteSmart($in)
|
||||||
{
|
{
|
||||||
if (is_int($in)) {
|
if (is_int($in)) {
|
||||||
return $in;
|
return $in;
|
||||||
@ -448,8 +448,7 @@ class DB_common extends PEAR
|
|||||||
return 'NULL';
|
return 'NULL';
|
||||||
} else {
|
} else {
|
||||||
if ($this->dbsyntax == 'access'
|
if ($this->dbsyntax == 'access'
|
||||||
&& preg_match('/^#.+#$/', $in))
|
&& preg_match('/^#.+#$/', $in)) {
|
||||||
{
|
|
||||||
return $this->escapeSimple($in);
|
return $this->escapeSimple($in);
|
||||||
}
|
}
|
||||||
return "'" . $this->escapeSimple($in) . "'";
|
return "'" . $this->escapeSimple($in) . "'";
|
||||||
@ -468,7 +467,8 @@ class DB_common extends PEAR
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since release 1.7.8.
|
* @since Method available since release 1.7.8.
|
||||||
*/
|
*/
|
||||||
function quoteBoolean($boolean) {
|
public function quoteBoolean($boolean)
|
||||||
|
{
|
||||||
return $boolean ? '1' : '0';
|
return $boolean ? '1' : '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +484,8 @@ class DB_common extends PEAR
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since release 1.7.8.
|
* @since Method available since release 1.7.8.
|
||||||
*/
|
*/
|
||||||
function quoteFloat($float) {
|
public function quoteFloat($float)
|
||||||
|
{
|
||||||
return "'".$this->escapeSimple(str_replace(',', '.', strval(floatval($float))))."'";
|
return "'".$this->escapeSimple(str_replace(',', '.', strval(floatval($float))))."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +507,7 @@ class DB_common extends PEAR
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function escapeSimple($str)
|
public function escapeSimple($str)
|
||||||
{
|
{
|
||||||
return str_replace("'", "''", $str);
|
return str_replace("'", "''", $str);
|
||||||
}
|
}
|
||||||
@ -521,7 +522,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @return bool whether this driver supports $feature
|
* @return bool whether this driver supports $feature
|
||||||
*/
|
*/
|
||||||
function provides($feature)
|
public function provides($feature)
|
||||||
{
|
{
|
||||||
return $this->features[$feature];
|
return $this->features[$feature];
|
||||||
}
|
}
|
||||||
@ -544,11 +545,12 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @see DB_FETCHMODE_ORDERED, DB_FETCHMODE_ASSOC, DB_FETCHMODE_OBJECT
|
* @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) {
|
switch ($fetchmode) {
|
||||||
case DB_FETCHMODE_OBJECT:
|
case DB_FETCHMODE_OBJECT:
|
||||||
$this->fetchmode_object_class = $object_class;
|
$this->fetchmode_object_class = $object_class;
|
||||||
|
// no break
|
||||||
case DB_FETCHMODE_ORDERED:
|
case DB_FETCHMODE_ORDERED:
|
||||||
case DB_FETCHMODE_ASSOC:
|
case DB_FETCHMODE_ASSOC:
|
||||||
$this->fetchmode = $fetchmode;
|
$this->fetchmode = $fetchmode;
|
||||||
@ -699,7 +701,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @see DB_common::$options
|
* @see DB_common::$options
|
||||||
*/
|
*/
|
||||||
function setOption($option, $value)
|
public function setOption($option, $value)
|
||||||
{
|
{
|
||||||
if (isset($this->options[$option])) {
|
if (isset($this->options[$option])) {
|
||||||
$this->options[$option] = $value;
|
$this->options[$option] = $value;
|
||||||
@ -744,7 +746,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @return mixed the option's value
|
* @return mixed the option's value
|
||||||
*/
|
*/
|
||||||
function getOption($option)
|
public function getOption($option)
|
||||||
{
|
{
|
||||||
if (isset($this->options[$option])) {
|
if (isset($this->options[$option])) {
|
||||||
return $this->options[$option];
|
return $this->options[$option];
|
||||||
@ -798,10 +800,14 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @see DB_common::execute()
|
* @see DB_common::execute()
|
||||||
*/
|
*/
|
||||||
function prepare($query)
|
public function prepare($query)
|
||||||
{
|
{
|
||||||
$tokens = preg_split('/((?<!\\\)[&?!])/', $query, -1,
|
$tokens = preg_split(
|
||||||
PREG_SPLIT_DELIM_CAPTURE);
|
'/((?<!\\\)[&?!])/',
|
||||||
|
$query,
|
||||||
|
-1,
|
||||||
|
PREG_SPLIT_DELIM_CAPTURE
|
||||||
|
);
|
||||||
$token = 0;
|
$token = 0;
|
||||||
$types = array();
|
$types = array();
|
||||||
$newtokens = array();
|
$newtokens = array();
|
||||||
@ -850,9 +856,12 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @uses DB_common::prepare(), DB_common::buildManipSQL()
|
* @uses DB_common::prepare(), DB_common::buildManipSQL()
|
||||||
*/
|
*/
|
||||||
function autoPrepare($table, $table_fields, $mode = DB_AUTOQUERY_INSERT,
|
public function autoPrepare(
|
||||||
$where = false)
|
$table,
|
||||||
{
|
$table_fields,
|
||||||
|
$mode = DB_AUTOQUERY_INSERT,
|
||||||
|
$where = false
|
||||||
|
) {
|
||||||
$query = $this->buildManipSQL($table, $table_fields, $mode, $where);
|
$query = $this->buildManipSQL($table, $table_fields, $mode, $where);
|
||||||
if (DB::isError($query)) {
|
if (DB::isError($query)) {
|
||||||
return $query;
|
return $query;
|
||||||
@ -882,18 +891,24 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @uses DB_common::autoPrepare(), DB_common::execute()
|
* @uses DB_common::autoPrepare(), DB_common::execute()
|
||||||
*/
|
*/
|
||||||
function autoExecute($table, $fields_values, $mode = DB_AUTOQUERY_INSERT,
|
public function autoExecute(
|
||||||
$where = false)
|
$table,
|
||||||
{
|
$fields_values,
|
||||||
$sth = $this->autoPrepare($table, array_keys($fields_values), $mode,
|
$mode = DB_AUTOQUERY_INSERT,
|
||||||
$where);
|
$where = false
|
||||||
|
) {
|
||||||
|
$sth = $this->autoPrepare(
|
||||||
|
$table,
|
||||||
|
array_keys($fields_values),
|
||||||
|
$mode,
|
||||||
|
$where
|
||||||
|
);
|
||||||
if (DB::isError($sth)) {
|
if (DB::isError($sth)) {
|
||||||
return $sth;
|
return $sth;
|
||||||
}
|
}
|
||||||
$ret = $this->execute($sth, array_values($fields_values));
|
$ret = $this->execute($sth, array_values($fields_values));
|
||||||
$this->freePrepared($sth);
|
$this->freePrepared($sth);
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -929,7 +944,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @return string the sql query for autoPrepare()
|
* @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) {
|
if (count($table_fields) == 0) {
|
||||||
return $this->raiseError(DB_ERROR_NEED_MORE_DATA);
|
return $this->raiseError(DB_ERROR_NEED_MORE_DATA);
|
||||||
@ -1002,7 +1017,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @see DB_common::prepare()
|
* @see DB_common::prepare()
|
||||||
*/
|
*/
|
||||||
function &execute($stmt, $data = array())
|
public function &execute($stmt, $data = array())
|
||||||
{
|
{
|
||||||
$realquery = $this->executeEmulateQuery($stmt, $data);
|
$realquery = $this->executeEmulateQuery($stmt, $data);
|
||||||
if (DB::isError($realquery)) {
|
if (DB::isError($realquery)) {
|
||||||
@ -1037,7 +1052,7 @@ class DB_common extends PEAR
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::execute()
|
* @see DB_common::execute()
|
||||||
*/
|
*/
|
||||||
function executeEmulateQuery($stmt, $data = array())
|
public function executeEmulateQuery($stmt, $data = array())
|
||||||
{
|
{
|
||||||
$stmt = (int)$stmt;
|
$stmt = (int)$stmt;
|
||||||
$data = (array)$data;
|
$data = (array)$data;
|
||||||
@ -1091,7 +1106,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @see DB_common::prepare(), DB_common::execute()
|
* @see DB_common::prepare(), DB_common::execute()
|
||||||
*/
|
*/
|
||||||
function executeMultiple($stmt, $data)
|
public function executeMultiple($stmt, $data)
|
||||||
{
|
{
|
||||||
foreach ($data as $value) {
|
foreach ($data as $value) {
|
||||||
$res = $this->execute($stmt, $value);
|
$res = $this->execute($stmt, $value);
|
||||||
@ -1117,7 +1132,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @see DB_common::prepare()
|
* @see DB_common::prepare()
|
||||||
*/
|
*/
|
||||||
function freePrepared($stmt, $free_resource = true)
|
public function freePrepared($stmt, $free_resource = true)
|
||||||
{
|
{
|
||||||
$stmt = (int)$stmt;
|
$stmt = (int)$stmt;
|
||||||
if (isset($this->prepare_tokens[$stmt])) {
|
if (isset($this->prepare_tokens[$stmt])) {
|
||||||
@ -1145,7 +1160,7 @@ class DB_common extends PEAR
|
|||||||
* @see DB_mysql::modifyQuery(), DB_oci8::modifyQuery(),
|
* @see DB_mysql::modifyQuery(), DB_oci8::modifyQuery(),
|
||||||
* DB_sqlite::modifyQuery()
|
* DB_sqlite::modifyQuery()
|
||||||
*/
|
*/
|
||||||
function modifyQuery($query)
|
public function modifyQuery($query)
|
||||||
{
|
{
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
@ -1172,7 +1187,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||||
{
|
{
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
@ -1200,7 +1215,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @see DB_result, DB_common::prepare(), DB_common::execute()
|
* @see DB_result, DB_common::prepare(), DB_common::execute()
|
||||||
*/
|
*/
|
||||||
function &query($query, $params = array())
|
public function &query($query, $params = array())
|
||||||
{
|
{
|
||||||
if (sizeof($params) > 0) {
|
if (sizeof($params) > 0) {
|
||||||
$sth = $this->prepare($query);
|
$sth = $this->prepare($query);
|
||||||
@ -1241,7 +1256,7 @@ class DB_common extends PEAR
|
|||||||
* or DB_OK for successul data manipulation queries.
|
* or DB_OK for successul data manipulation queries.
|
||||||
* A DB_Error object on failure.
|
* 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);
|
$query = $this->modifyLimitQuery($query, $from, $count, $params);
|
||||||
if (DB::isError($query)) {
|
if (DB::isError($query)) {
|
||||||
@ -1273,7 +1288,7 @@ class DB_common extends PEAR
|
|||||||
* @return mixed the returned value of the query.
|
* @return mixed the returned value of the query.
|
||||||
* A DB_Error object on failure.
|
* A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function &getOne($query, $params = array())
|
public function &getOne($query, $params = array())
|
||||||
{
|
{
|
||||||
$params = (array)$params;
|
$params = (array)$params;
|
||||||
// modifyLimitQuery() would be nice here, but it causes BC issues
|
// 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.
|
* @return array the first row of results as an array.
|
||||||
* A DB_Error object on failure.
|
* A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function &getRow($query, $params = array(),
|
public function &getRow(
|
||||||
$fetchmode = DB_FETCHMODE_DEFAULT)
|
$query,
|
||||||
{
|
$params = array(),
|
||||||
|
$fetchmode = DB_FETCHMODE_DEFAULT
|
||||||
|
) {
|
||||||
// compat check, the params and fetchmode parameters used to
|
// compat check, the params and fetchmode parameters used to
|
||||||
// have the opposite order
|
// have the opposite order
|
||||||
if (!is_array($params)) {
|
if (!is_array($params)) {
|
||||||
@ -1387,7 +1404,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @see DB_common::query()
|
* @see DB_common::query()
|
||||||
*/
|
*/
|
||||||
function &getCol($query, $col = 0, $params = array())
|
public function &getCol($query, $col = 0, $params = array())
|
||||||
{
|
{
|
||||||
$params = (array)$params;
|
$params = (array)$params;
|
||||||
if (sizeof($params) > 0) {
|
if (sizeof($params) > 0) {
|
||||||
@ -1518,9 +1535,13 @@ class DB_common extends PEAR
|
|||||||
* @return array the associative array containing the query results.
|
* @return array the associative array containing the query results.
|
||||||
* A DB_Error object on failure.
|
* A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function &getAssoc($query, $force_array = false, $params = array(),
|
public function &getAssoc(
|
||||||
$fetchmode = DB_FETCHMODE_DEFAULT, $group = false)
|
$query,
|
||||||
{
|
$force_array = false,
|
||||||
|
$params = array(),
|
||||||
|
$fetchmode = DB_FETCHMODE_DEFAULT,
|
||||||
|
$group = false
|
||||||
|
) {
|
||||||
$params = (array)$params;
|
$params = (array)$params;
|
||||||
if (sizeof($params) > 0) {
|
if (sizeof($params) > 0) {
|
||||||
$sth = $this->prepare($query);
|
$sth = $this->prepare($query);
|
||||||
@ -1629,9 +1650,11 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @return array the nested array. A DB_Error object on failure.
|
* @return array the nested array. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function &getAll($query, $params = array(),
|
public function &getAll(
|
||||||
$fetchmode = DB_FETCHMODE_DEFAULT)
|
$query,
|
||||||
{
|
$params = array(),
|
||||||
|
$fetchmode = DB_FETCHMODE_DEFAULT
|
||||||
|
) {
|
||||||
// compat check, the params and fetchmode parameters used to
|
// compat check, the params and fetchmode parameters used to
|
||||||
// have the opposite order
|
// have the opposite order
|
||||||
if (!is_array($params)) {
|
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
|
* @return int DB_OK on success. A DB_Error object if the driver
|
||||||
* doesn't support auto-committing transactions.
|
* doesn't support auto-committing transactions.
|
||||||
*/
|
*/
|
||||||
function autoCommit($onoff = false)
|
public function autoCommit($onoff = false)
|
||||||
{
|
{
|
||||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
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.
|
* @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);
|
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.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||||
}
|
}
|
||||||
@ -1775,10 +1798,12 @@ class DB_common extends PEAR
|
|||||||
* @see DB_common::createSequence(), DB_common::dropSequence(),
|
* @see DB_common::createSequence(), DB_common::dropSequence(),
|
||||||
* DB_common::nextID(), DB_common::setOption()
|
* DB_common::nextID(), DB_common::setOption()
|
||||||
*/
|
*/
|
||||||
function getSequenceName($sqn)
|
public function getSequenceName($sqn)
|
||||||
{
|
{
|
||||||
return sprintf($this->getOption('seqname_format'),
|
return sprintf(
|
||||||
preg_replace('/[^a-z0-9_.]/i', '_', $sqn));
|
$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(),
|
* @see DB_common::createSequence(), DB_common::dropSequence(),
|
||||||
* DB_common::getSequenceName()
|
* DB_common::getSequenceName()
|
||||||
*/
|
*/
|
||||||
function nextId($seq_name, $ondemand = true)
|
public function nextId($seq_name, $ondemand = true)
|
||||||
{
|
{
|
||||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||||
}
|
}
|
||||||
@ -1822,7 +1847,7 @@ class DB_common extends PEAR
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_common::nextID()
|
* DB_common::nextID()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||||
}
|
}
|
||||||
@ -1840,7 +1865,7 @@ class DB_common extends PEAR
|
|||||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_common::nextID()
|
* DB_common::nextID()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||||
}
|
}
|
||||||
@ -1876,10 +1901,15 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @see PEAR_Error
|
* @see PEAR_Error
|
||||||
*/
|
*/
|
||||||
function &raiseError($code = DB_ERROR, $mode = null, $options = null,
|
public function &raiseError(
|
||||||
$userinfo = null, $nativecode = null, $dummy1 = null,
|
$code = DB_ERROR,
|
||||||
$dummy2 = null)
|
$mode = null,
|
||||||
{
|
$options = null,
|
||||||
|
$userinfo = null,
|
||||||
|
$nativecode = null,
|
||||||
|
$dummy1 = null,
|
||||||
|
$dummy2 = null
|
||||||
|
) {
|
||||||
// The error is yet a DB error object
|
// The error is yet a DB error object
|
||||||
if (is_object($code)) {
|
if (is_object($code)) {
|
||||||
// because we the static PEAR::raiseError, our global
|
// because we the static PEAR::raiseError, our global
|
||||||
@ -1888,8 +1918,15 @@ class DB_common extends PEAR
|
|||||||
$mode = $this->_default_error_mode;
|
$mode = $this->_default_error_mode;
|
||||||
$options = $this->_default_error_options;
|
$options = $this->_default_error_options;
|
||||||
}
|
}
|
||||||
$tmp = PEAR::raiseError($code, null, $mode, $options,
|
$tmp = PEAR::raiseError(
|
||||||
null, null, true);
|
$code,
|
||||||
|
null,
|
||||||
|
$mode,
|
||||||
|
$options,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1903,8 +1940,15 @@ class DB_common extends PEAR
|
|||||||
$userinfo .= ' [DB Error: ' . DB::errorMessage($code) . ']';
|
$userinfo .= ' [DB Error: ' . DB::errorMessage($code) . ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp = PEAR::raiseError(null, $code, $mode, $options, $userinfo,
|
$tmp = PEAR::raiseError(
|
||||||
'DB_Error', true);
|
null,
|
||||||
|
$code,
|
||||||
|
$mode,
|
||||||
|
$options,
|
||||||
|
$userinfo,
|
||||||
|
'DB_Error',
|
||||||
|
true
|
||||||
|
);
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1916,7 +1960,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @return mixed the DBMS' error code. A DB_Error object on failure.
|
* @return mixed the DBMS' error code. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
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
|
* current driver doesn't have a mapping for the
|
||||||
* $nativecode submitted.
|
* $nativecode submitted.
|
||||||
*/
|
*/
|
||||||
function errorCode($nativecode)
|
public function errorCode($nativecode)
|
||||||
{
|
{
|
||||||
if (isset($this->errorcode_map[$nativecode])) {
|
if (isset($this->errorcode_map[$nativecode])) {
|
||||||
return $this->errorcode_map[$nativecode];
|
return $this->errorcode_map[$nativecode];
|
||||||
@ -1957,7 +2001,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @see DB::errorMessage()
|
* @see DB::errorMessage()
|
||||||
*/
|
*/
|
||||||
function errorMessage($dbcode)
|
public function errorMessage($dbcode)
|
||||||
{
|
{
|
||||||
return DB::errorMessage($this->errorcode_map[$dbcode]);
|
return DB::errorMessage($this->errorcode_map[$dbcode]);
|
||||||
}
|
}
|
||||||
@ -2085,7 +2129,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @see DB_common::setOption()
|
* @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
|
* 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
|
* @deprecated Method deprecated some time before Release 1.2
|
||||||
*/
|
*/
|
||||||
function getTables()
|
public function getTables()
|
||||||
{
|
{
|
||||||
return $this->getListOf('tables');
|
return $this->getListOf('tables');
|
||||||
}
|
}
|
||||||
@ -2124,7 +2168,7 @@ class DB_common extends PEAR
|
|||||||
* @return array an array listing the items sought.
|
* @return array an array listing the items sought.
|
||||||
* A DB DB_Error object on failure.
|
* A DB DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function getListOf($type)
|
public function getListOf($type)
|
||||||
{
|
{
|
||||||
$sql = $this->getSpecialQuery($type);
|
$sql = $this->getSpecialQuery($type);
|
||||||
if ($sql === null) {
|
if ($sql === null) {
|
||||||
@ -2155,7 +2199,7 @@ class DB_common extends PEAR
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
return $this->raiseError(DB_ERROR_UNSUPPORTED);
|
return $this->raiseError(DB_ERROR_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
@ -2174,7 +2218,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function nextQueryIsManip($manip)
|
public function nextQueryIsManip($manip)
|
||||||
{
|
{
|
||||||
$this->_next_query_manip = $manip;
|
$this->_next_query_manip = $manip;
|
||||||
}
|
}
|
||||||
@ -2194,7 +2238,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function _checkManip($query)
|
public function _checkManip($query)
|
||||||
{
|
{
|
||||||
if ($this->_next_query_manip || DB::isManip($query)) {
|
if ($this->_next_query_manip || DB::isManip($query)) {
|
||||||
$this->_last_query_manip = true;
|
$this->_last_query_manip = true;
|
||||||
@ -2218,7 +2262,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function _rtrimArrayValues(&$array)
|
public function _rtrimArrayValues(&$array)
|
||||||
{
|
{
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
if (is_string($value)) {
|
if (is_string($value)) {
|
||||||
@ -2239,7 +2283,7 @@ class DB_common extends PEAR
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function _convertNullArrayValuesToEmpty(&$array)
|
public function _convertNullArrayValuesToEmpty(&$array)
|
||||||
{
|
{
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
@ -2257,5 +2301,3 @@ class DB_common extends PEAR
|
|||||||
* c-basic-offset: 4
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -52,13 +52,13 @@ class DB_dbase extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'dbase';
|
public $phptype = 'dbase';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'dbase';
|
public $dbsyntax = 'dbase';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -73,7 +73,7 @@ class DB_dbase extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => false,
|
'limit' => false,
|
||||||
'new_link' => false,
|
'new_link' => false,
|
||||||
'numrows' => true,
|
'numrows' => true,
|
||||||
@ -87,27 +87,27 @@ class DB_dbase extends DB_common
|
|||||||
* A mapping of native error codes to DB error codes
|
* A mapping of native error codes to DB error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The raw database connection created by PHP
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A means of emulating result resources
|
* A means of emulating result resources
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $res_row = array();
|
public $res_row = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The quantity of results so far
|
* The quantity of results so far
|
||||||
@ -116,7 +116,7 @@ class DB_dbase extends DB_common
|
|||||||
*
|
*
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
var $result = 0;
|
public $result = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps dbase data type id's to human readable strings
|
* Maps dbase data type id's to human readable strings
|
||||||
@ -127,7 +127,7 @@ class DB_dbase extends DB_common
|
|||||||
* @var array
|
* @var array
|
||||||
* @since Property available since Release 1.7.0
|
* @since Property available since Release 1.7.0
|
||||||
*/
|
*/
|
||||||
var $types = array(
|
public $types = array(
|
||||||
'C' => 'character',
|
'C' => 'character',
|
||||||
'D' => 'date',
|
'D' => 'date',
|
||||||
'L' => 'boolean',
|
'L' => 'boolean',
|
||||||
@ -144,7 +144,7 @@ class DB_dbase extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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')) {
|
if (!PEAR::loadExtension('dbase')) {
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||||
@ -220,32 +220,48 @@ class DB_dbase extends DB_common
|
|||||||
if (!file_exists($dsn['database'])) {
|
if (!file_exists($dsn['database'])) {
|
||||||
$this->dsn['mode'] = 2;
|
$this->dsn['mode'] = 2;
|
||||||
if (empty($dsn['fields']) || !is_array($dsn['fields'])) {
|
if (empty($dsn['fields']) || !is_array($dsn['fields'])) {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
'the dbase file does not exist and '
|
'the dbase file does not exist and '
|
||||||
. 'it could not be created because '
|
. 'it could not be created because '
|
||||||
. 'the "fields" element of the DSN '
|
. 'the "fields" element of the DSN '
|
||||||
. 'is not properly set');
|
. 'is not properly set'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->connection = @dbase_create($dsn['database'],
|
$this->connection = @dbase_create(
|
||||||
$dsn['fields']);
|
$dsn['database'],
|
||||||
|
$dsn['fields']
|
||||||
|
);
|
||||||
if (!$this->connection) {
|
if (!$this->connection) {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
'the dbase file does not exist and '
|
'the dbase file does not exist and '
|
||||||
. 'the attempt to create it failed: '
|
. 'the attempt to create it failed: '
|
||||||
. $php_errormsg);
|
. $php_errormsg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($this->dsn['mode'])) {
|
if (!isset($this->dsn['mode'])) {
|
||||||
$this->dsn['mode'] = 0;
|
$this->dsn['mode'] = 0;
|
||||||
}
|
}
|
||||||
$this->connection = @dbase_open($dsn['database'],
|
$this->connection = @dbase_open(
|
||||||
$this->dsn['mode']);
|
$dsn['database'],
|
||||||
|
$this->dsn['mode']
|
||||||
|
);
|
||||||
if (!$this->connection) {
|
if (!$this->connection) {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$php_errormsg);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$php_errormsg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DB_OK;
|
return DB_OK;
|
||||||
@ -259,7 +275,7 @@ class DB_dbase extends DB_common
|
|||||||
*
|
*
|
||||||
* @return bool TRUE on success, FALSE on failure
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$ret = @dbase_close($this->connection);
|
$ret = @dbase_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -269,7 +285,7 @@ class DB_dbase extends DB_common
|
|||||||
// }}}
|
// }}}
|
||||||
// {{{ &query()
|
// {{{ &query()
|
||||||
|
|
||||||
function &query($query = null)
|
public function &query($query = null)
|
||||||
{
|
{
|
||||||
// emulate result resources
|
// emulate result resources
|
||||||
$this->res_row[(int)$this->result] = 0;
|
$this->res_row[(int)$this->result] = 0;
|
||||||
@ -300,7 +316,7 @@ class DB_dbase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
if ($rownum === null) {
|
if ($rownum === null) {
|
||||||
$rownum = $this->res_row[(int)$result]++;
|
$rownum = $this->res_row[(int)$result]++;
|
||||||
@ -340,7 +356,7 @@ class DB_dbase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -361,7 +377,7 @@ class DB_dbase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($foo)
|
public function numCols($foo)
|
||||||
{
|
{
|
||||||
return @dbase_numfields($this->connection);
|
return @dbase_numfields($this->connection);
|
||||||
}
|
}
|
||||||
@ -382,7 +398,7 @@ class DB_dbase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numRows()
|
* @see DB_result::numRows()
|
||||||
*/
|
*/
|
||||||
function numRows($foo)
|
public function numRows($foo)
|
||||||
{
|
{
|
||||||
return @dbase_numrecords($this->connection);
|
return @dbase_numrecords($this->connection);
|
||||||
}
|
}
|
||||||
@ -399,7 +415,8 @@ class DB_dbase extends DB_common
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since release 1.7.8.
|
* @since Method available since release 1.7.8.
|
||||||
*/
|
*/
|
||||||
function quoteBoolean($boolean) {
|
public function quoteBoolean($boolean)
|
||||||
|
{
|
||||||
return $boolean ? 'T' : 'F';
|
return $boolean ? 'T' : 'F';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,14 +436,18 @@ class DB_dbase extends DB_common
|
|||||||
* @see DB_common::tableInfo()
|
* @see DB_common::tableInfo()
|
||||||
* @since Method available since Release 1.7.0
|
* @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')) {
|
if (function_exists('dbase_get_header_info')) {
|
||||||
$id = @dbase_get_header_info($this->connection);
|
$id = @dbase_get_header_info($this->connection);
|
||||||
if (!$id && $php_errormsg) {
|
if (!$id && $php_errormsg) {
|
||||||
return $this->raiseError(DB_ERROR,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR,
|
||||||
$php_errormsg);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$php_errormsg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -436,9 +457,13 @@ class DB_dbase extends DB_common
|
|||||||
*/
|
*/
|
||||||
$db = @fopen($this->dsn['database'], 'r');
|
$db = @fopen($this->dsn['database'], 'r');
|
||||||
if (!$db) {
|
if (!$db) {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$php_errormsg);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$php_errormsg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = array();
|
$id = array();
|
||||||
@ -506,5 +531,3 @@ class DB_dbase extends DB_common
|
|||||||
* c-basic-offset: 4
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -53,13 +53,13 @@ class DB_fbsql extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'fbsql';
|
public $phptype = 'fbsql';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'fbsql';
|
public $dbsyntax = 'fbsql';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -74,7 +74,7 @@ class DB_fbsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => 'alter',
|
'limit' => 'alter',
|
||||||
'new_link' => false,
|
'new_link' => false,
|
||||||
'numrows' => true,
|
'numrows' => true,
|
||||||
@ -88,7 +88,7 @@ class DB_fbsql extends DB_common
|
|||||||
* A mapping of native error codes to DB error codes
|
* A mapping of native error codes to DB error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
22 => DB_ERROR_SYNTAX,
|
22 => DB_ERROR_SYNTAX,
|
||||||
85 => DB_ERROR_ALREADY_EXISTS,
|
85 => DB_ERROR_ALREADY_EXISTS,
|
||||||
108 => DB_ERROR_SYNTAX,
|
108 => DB_ERROR_SYNTAX,
|
||||||
@ -111,13 +111,13 @@ class DB_fbsql extends DB_common
|
|||||||
* The raw database connection created by PHP
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -128,7 +128,7 @@ class DB_fbsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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')) {
|
if (!PEAR::loadExtension('fbsql')) {
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||||
@ -168,19 +168,27 @@ class DB_fbsql extends DB_common
|
|||||||
$ini = ini_get('track_errors');
|
$ini = ini_get('track_errors');
|
||||||
$php_errormsg = '';
|
$php_errormsg = '';
|
||||||
if ($ini) {
|
if ($ini) {
|
||||||
$this->connection = @call_user_func_array($connect_function,
|
$this->connection = @call_user_func_array(
|
||||||
$params);
|
$connect_function,
|
||||||
|
$params
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
@ini_set('track_errors', 1);
|
@ini_set('track_errors', 1);
|
||||||
$this->connection = @call_user_func_array($connect_function,
|
$this->connection = @call_user_func_array(
|
||||||
$params);
|
$connect_function,
|
||||||
|
$params
|
||||||
|
);
|
||||||
@ini_set('track_errors', $ini);
|
@ini_set('track_errors', $ini);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->connection) {
|
if (!$this->connection) {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$php_errormsg);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$php_errormsg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($dsn['database']) {
|
if ($dsn['database']) {
|
||||||
@ -200,7 +208,7 @@ class DB_fbsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return bool TRUE on success, FALSE on failure
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$ret = @fbsql_close($this->connection);
|
$ret = @fbsql_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -219,7 +227,7 @@ class DB_fbsql extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$this->last_query = $query;
|
$this->last_query = $query;
|
||||||
$query = $this->modifyQuery($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
|
* @return true if a result is available otherwise return false
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return @fbsql_next_result($result);
|
return @fbsql_next_result($result);
|
||||||
}
|
}
|
||||||
@ -275,7 +283,7 @@ class DB_fbsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
if ($rownum !== null) {
|
if ($rownum !== null) {
|
||||||
if (!@fbsql_data_seek($result, $rownum)) {
|
if (!@fbsql_data_seek($result, $rownum)) {
|
||||||
@ -318,7 +326,7 @@ class DB_fbsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
return is_resource($result) ? fbsql_free_result($result) : false;
|
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
|
* @return int DB_OK on success. A DB_Error object if the driver
|
||||||
* doesn't support auto-committing transactions.
|
* doesn't support auto-committing transactions.
|
||||||
*/
|
*/
|
||||||
function autoCommit($onoff=false)
|
public function autoCommit($onoff=false)
|
||||||
{
|
{
|
||||||
if ($onoff) {
|
if ($onoff) {
|
||||||
$this->query("SET COMMIT TRUE");
|
$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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
@fbsql_commit($this->connection);
|
@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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
@fbsql_rollback($this->connection);
|
@fbsql_rollback($this->connection);
|
||||||
}
|
}
|
||||||
@ -385,7 +393,7 @@ class DB_fbsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
$cols = @fbsql_num_fields($result);
|
$cols = @fbsql_num_fields($result);
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
@ -410,7 +418,7 @@ class DB_fbsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numRows()
|
* @see DB_result::numRows()
|
||||||
*/
|
*/
|
||||||
function numRows($result)
|
public function numRows($result)
|
||||||
{
|
{
|
||||||
$rows = @fbsql_num_rows($result);
|
$rows = @fbsql_num_rows($result);
|
||||||
if ($rows === null) {
|
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.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
if ($this->_last_query_manip) {
|
if ($this->_last_query_manip) {
|
||||||
$result = @fbsql_affected_rows($this->connection);
|
$result = @fbsql_affected_rows($this->connection);
|
||||||
@ -455,7 +463,7 @@ class DB_fbsql extends DB_common
|
|||||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||||
* DB_fbsql::createSequence(), DB_fbsql::dropSequence()
|
* DB_fbsql::createSequence(), DB_fbsql::dropSequence()
|
||||||
*/
|
*/
|
||||||
function nextId($seq_name, $ondemand = true)
|
public function nextId($seq_name, $ondemand = true)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
do {
|
do {
|
||||||
@ -491,7 +499,7 @@ class DB_fbsql extends DB_common
|
|||||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_fbsql::nextID(), DB_fbsql::dropSequence()
|
* DB_fbsql::nextID(), DB_fbsql::dropSequence()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
$res = $this->query('CREATE TABLE ' . $seqname
|
$res = $this->query('CREATE TABLE ' . $seqname
|
||||||
@ -516,7 +524,7 @@ class DB_fbsql extends DB_common
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_fbsql::nextID(), DB_fbsql::createSequence()
|
* DB_fbsql::nextID(), DB_fbsql::createSequence()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name)
|
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name)
|
||||||
. ' RESTRICT');
|
. ' RESTRICT');
|
||||||
@ -541,14 +549,20 @@ class DB_fbsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @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) {
|
if (DB::isManip($query) || $this->_next_query_manip) {
|
||||||
return preg_replace('/^([\s(])*SELECT/i',
|
return preg_replace(
|
||||||
"\\1SELECT TOP($count)", $query);
|
'/^([\s(])*SELECT/i',
|
||||||
|
"\\1SELECT TOP($count)",
|
||||||
|
$query
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return preg_replace('/([\s(])*SELECT/i',
|
return preg_replace(
|
||||||
"\\1SELECT TOP($from, $count)", $query);
|
'/([\s(])*SELECT/i',
|
||||||
|
"\\1SELECT TOP($from, $count)",
|
||||||
|
$query
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,7 +578,8 @@ class DB_fbsql extends DB_common
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since release 1.7.8.
|
* @since Method available since release 1.7.8.
|
||||||
*/
|
*/
|
||||||
function quoteBoolean($boolean) {
|
public function quoteBoolean($boolean)
|
||||||
|
{
|
||||||
return $boolean ? 'TRUE' : 'FALSE';
|
return $boolean ? 'TRUE' : 'FALSE';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,7 +595,8 @@ class DB_fbsql extends DB_common
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since release 1.7.8.
|
* @since Method available since release 1.7.8.
|
||||||
*/
|
*/
|
||||||
function quoteFloat($float) {
|
public function quoteFloat($float)
|
||||||
|
{
|
||||||
return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
|
return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,13 +615,18 @@ class DB_fbsql extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_fbsql::errorNative(), DB_common::errorCode()
|
* DB_fbsql::errorNative(), DB_common::errorCode()
|
||||||
*/
|
*/
|
||||||
function fbsqlRaiseError($errno = null)
|
public function fbsqlRaiseError($errno = null)
|
||||||
{
|
{
|
||||||
if ($errno === null) {
|
if ($errno === null) {
|
||||||
$errno = $this->errorCode(fbsql_errno($this->connection));
|
$errno = $this->errorCode(fbsql_errno($this->connection));
|
||||||
}
|
}
|
||||||
return $this->raiseError($errno, null, null, null,
|
return $this->raiseError(
|
||||||
@fbsql_error($this->connection));
|
$errno,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
@fbsql_error($this->connection)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -616,7 +637,7 @@ class DB_fbsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return int the DBMS' error code
|
* @return int the DBMS' error code
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
return @fbsql_errno($this->connection);
|
return @fbsql_errno($this->connection);
|
||||||
}
|
}
|
||||||
@ -639,15 +660,18 @@ class DB_fbsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_common::tableInfo()
|
* @see DB_common::tableInfo()
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if (is_string($result)) {
|
if (is_string($result)) {
|
||||||
/*
|
/*
|
||||||
* Probably received a table name.
|
* Probably received a table name.
|
||||||
* Create a result resource identifier.
|
* Create a result resource identifier.
|
||||||
*/
|
*/
|
||||||
$id = @fbsql_list_fields($this->dsn['database'],
|
$id = @fbsql_list_fields(
|
||||||
$result, $this->connection);
|
$this->dsn['database'],
|
||||||
|
$result,
|
||||||
|
$this->connection
|
||||||
|
);
|
||||||
$got_string = true;
|
$got_string = true;
|
||||||
} elseif (isset($result->result)) {
|
} elseif (isset($result->result)) {
|
||||||
/*
|
/*
|
||||||
@ -720,7 +744,7 @@ class DB_fbsql extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'tables':
|
case 'tables':
|
||||||
@ -765,5 +789,3 @@ class DB_fbsql extends DB_common
|
|||||||
* c-basic-offset: 4
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -61,13 +61,13 @@ class DB_ibase extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'ibase';
|
public $phptype = 'ibase';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'ibase';
|
public $dbsyntax = 'ibase';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -84,7 +84,7 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => false,
|
'limit' => false,
|
||||||
'new_link' => false,
|
'new_link' => false,
|
||||||
'numrows' => 'emulate',
|
'numrows' => 'emulate',
|
||||||
@ -98,7 +98,7 @@ class DB_ibase extends DB_common
|
|||||||
* A mapping of native error codes to DB error codes
|
* A mapping of native error codes to DB error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
-104 => DB_ERROR_SYNTAX,
|
-104 => DB_ERROR_SYNTAX,
|
||||||
-150 => DB_ERROR_ACCESS_VIOLATION,
|
-150 => DB_ERROR_ACCESS_VIOLATION,
|
||||||
-151 => 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
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -148,14 +148,14 @@ class DB_ibase extends DB_common
|
|||||||
* @var integer
|
* @var integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $affected = 0;
|
public $affected = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should data manipulation queries be committed automatically?
|
* Should data manipulation queries be committed automatically?
|
||||||
* @var bool
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $autocommit = true;
|
public $autocommit = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The prepared statement handle from the most recently executed statement
|
* The prepared statement handle from the most recently executed statement
|
||||||
@ -166,14 +166,14 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $last_stmt;
|
public $last_stmt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the given prepared statement a data manipulation query?
|
* Is the given prepared statement a data manipulation query?
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $manip_query = array();
|
public $manip_query = array();
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -184,7 +184,7 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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')) {
|
if (!PEAR::loadExtension('interbase')) {
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
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
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$ret = @ibase_close($this->connection);
|
$ret = @ibase_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -274,7 +274,7 @@ class DB_ibase extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$ismanip = $this->_checkManip($query);
|
$ismanip = $this->_checkManip($query);
|
||||||
$this->last_query = $query;
|
$this->last_query = $query;
|
||||||
@ -317,11 +317,14 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||||
{
|
{
|
||||||
if ($this->dsn['dbsyntax'] == 'firebird') {
|
if ($this->dsn['dbsyntax'] == 'firebird') {
|
||||||
$query = preg_replace('/^([\s(])*SELECT/i',
|
$query = preg_replace(
|
||||||
"SELECT FIRST $count SKIP $from", $query);
|
'/^([\s(])*SELECT/i',
|
||||||
|
"SELECT FIRST $count SKIP $from",
|
||||||
|
$query
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
@ -338,7 +341,7 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @return true if a result is available otherwise return false
|
* @return true if a result is available otherwise return false
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -366,7 +369,7 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
if ($rownum !== null) {
|
if ($rownum !== null) {
|
||||||
return $this->ibaseRaiseError(DB_ERROR_NOT_CAPABLE);
|
return $this->ibaseRaiseError(DB_ERROR_NOT_CAPABLE);
|
||||||
@ -411,7 +414,7 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
return is_resource($result) ? ibase_free_result($result) : false;
|
return is_resource($result) ? ibase_free_result($result) : false;
|
||||||
}
|
}
|
||||||
@ -419,7 +422,7 @@ class DB_ibase extends DB_common
|
|||||||
// }}}
|
// }}}
|
||||||
// {{{ freeQuery()
|
// {{{ freeQuery()
|
||||||
|
|
||||||
function freeQuery($query)
|
public function freeQuery($query)
|
||||||
{
|
{
|
||||||
return is_resource($query) ? ibase_free_query($query) : false;
|
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.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
if (is_integer($this->affected)) {
|
if (is_integer($this->affected)) {
|
||||||
return $this->affected;
|
return $this->affected;
|
||||||
@ -458,7 +461,7 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
$cols = @ibase_num_fields($result);
|
$cols = @ibase_num_fields($result);
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
@ -492,10 +495,14 @@ class DB_ibase extends DB_common
|
|||||||
* @param string $query query to be prepared
|
* @param string $query query to be prepared
|
||||||
* @return mixed DB statement resource on success. DB_Error on failure.
|
* @return mixed DB statement resource on success. DB_Error on failure.
|
||||||
*/
|
*/
|
||||||
function prepare($query)
|
public function prepare($query)
|
||||||
{
|
{
|
||||||
$tokens = preg_split('/((?<!\\\)[&?!])/', $query, -1,
|
$tokens = preg_split(
|
||||||
PREG_SPLIT_DELIM_CAPTURE);
|
'/((?<!\\\)[&?!])/',
|
||||||
|
$query,
|
||||||
|
-1,
|
||||||
|
PREG_SPLIT_DELIM_CAPTURE
|
||||||
|
);
|
||||||
$token = 0;
|
$token = 0;
|
||||||
$types = array();
|
$types = array();
|
||||||
$newquery = '';
|
$newquery = '';
|
||||||
@ -548,7 +555,7 @@ class DB_ibase extends DB_common
|
|||||||
* @see DB_ibase::prepare()
|
* @see DB_ibase::prepare()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function &execute($stmt, $data = array())
|
public function &execute($stmt, $data = array())
|
||||||
{
|
{
|
||||||
$data = (array)$data;
|
$data = (array)$data;
|
||||||
$this->last_parameters = $data;
|
$this->last_parameters = $data;
|
||||||
@ -618,7 +625,7 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_ibase::prepare()
|
* @see DB_ibase::prepare()
|
||||||
*/
|
*/
|
||||||
function freePrepared($stmt, $free_resource = true)
|
public function freePrepared($stmt, $free_resource = true)
|
||||||
{
|
{
|
||||||
if (!is_resource($stmt)) {
|
if (!is_resource($stmt)) {
|
||||||
return false;
|
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
|
* @return int DB_OK on success. A DB_Error object if the driver
|
||||||
* doesn't support auto-committing transactions.
|
* doesn't support auto-committing transactions.
|
||||||
*/
|
*/
|
||||||
function autoCommit($onoff = false)
|
public function autoCommit($onoff = false)
|
||||||
{
|
{
|
||||||
$this->autocommit = $onoff ? 1 : 0;
|
$this->autocommit = $onoff ? 1 : 0;
|
||||||
return DB_OK;
|
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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
return @ibase_commit($this->connection);
|
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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
return @ibase_rollback($this->connection);
|
return @ibase_rollback($this->connection);
|
||||||
}
|
}
|
||||||
@ -678,7 +685,7 @@ class DB_ibase extends DB_common
|
|||||||
// }}}
|
// }}}
|
||||||
// {{{ transactionInit()
|
// {{{ transactionInit()
|
||||||
|
|
||||||
function transactionInit($trans_args = 0)
|
public function transactionInit($trans_args = 0)
|
||||||
{
|
{
|
||||||
return $trans_args
|
return $trans_args
|
||||||
? @ibase_trans($trans_args, $this->connection)
|
? @ibase_trans($trans_args, $this->connection)
|
||||||
@ -701,7 +708,7 @@ class DB_ibase extends DB_common
|
|||||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||||
* DB_ibase::createSequence(), DB_ibase::dropSequence()
|
* 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));
|
$sqn = strtoupper($this->getSequenceName($seq_name));
|
||||||
$repeat = 0;
|
$repeat = 0;
|
||||||
@ -742,7 +749,7 @@ class DB_ibase extends DB_common
|
|||||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_ibase::nextID(), DB_ibase::dropSequence()
|
* DB_ibase::nextID(), DB_ibase::dropSequence()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
$sqn = strtoupper($this->getSequenceName($seq_name));
|
$sqn = strtoupper($this->getSequenceName($seq_name));
|
||||||
$this->pushErrorHandling(PEAR_ERROR_RETURN);
|
$this->pushErrorHandling(PEAR_ERROR_RETURN);
|
||||||
@ -765,7 +772,7 @@ class DB_ibase extends DB_common
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_ibase::nextID(), DB_ibase::createSequence()
|
* DB_ibase::nextID(), DB_ibase::createSequence()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('DELETE FROM RDB$GENERATORS '
|
return $this->query('DELETE FROM RDB$GENERATORS '
|
||||||
. "WHERE RDB\$GENERATOR_NAME='"
|
. "WHERE RDB\$GENERATOR_NAME='"
|
||||||
@ -789,7 +796,7 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _ibaseFieldFlags($field_name, $table_name)
|
public function _ibaseFieldFlags($field_name, $table_name)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT R.RDB$CONSTRAINT_TYPE CTYPE'
|
$sql = 'SELECT R.RDB$CONSTRAINT_TYPE CTYPE'
|
||||||
.' FROM RDB$INDEX_SEGMENTS I'
|
.' FROM RDB$INDEX_SEGMENTS I'
|
||||||
@ -860,7 +867,7 @@ class DB_ibase extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_ibase::errorNative(), DB_ibase::errorCode()
|
* DB_ibase::errorNative(), DB_ibase::errorCode()
|
||||||
*/
|
*/
|
||||||
function &ibaseRaiseError($errno = null)
|
public function &ibaseRaiseError($errno = null)
|
||||||
{
|
{
|
||||||
if ($errno === null) {
|
if ($errno === null) {
|
||||||
$errno = $this->errorCode($this->errorNative());
|
$errno = $this->errorCode($this->errorNative());
|
||||||
@ -879,13 +886,16 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @since Method available since Release 1.7.0
|
* @since Method available since Release 1.7.0
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
if (function_exists('ibase_errcode')) {
|
if (function_exists('ibase_errcode')) {
|
||||||
return @ibase_errcode();
|
return @ibase_errcode();
|
||||||
}
|
}
|
||||||
if (preg_match('/^Dynamic SQL Error SQL error code = ([0-9-]+)/i',
|
if (preg_match(
|
||||||
@ibase_errmsg(), $m)) {
|
'/^Dynamic SQL Error SQL error code = ([0-9-]+)/i',
|
||||||
|
@ibase_errmsg(),
|
||||||
|
$m
|
||||||
|
)) {
|
||||||
return (int)$m[1];
|
return (int)$m[1];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -905,7 +915,7 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @since Method available since Release 1.7.0
|
* @since Method available since Release 1.7.0
|
||||||
*/
|
*/
|
||||||
function errorCode($nativecode = null)
|
public function errorCode($nativecode = null)
|
||||||
{
|
{
|
||||||
if (isset($this->errorcode_map[$nativecode])) {
|
if (isset($this->errorcode_map[$nativecode])) {
|
||||||
return $this->errorcode_map[$nativecode];
|
return $this->errorcode_map[$nativecode];
|
||||||
@ -969,15 +979,17 @@ class DB_ibase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_common::tableInfo()
|
* @see DB_common::tableInfo()
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if (is_string($result)) {
|
if (is_string($result)) {
|
||||||
/*
|
/*
|
||||||
* Probably received a table name.
|
* Probably received a table name.
|
||||||
* Create a result resource identifier.
|
* Create a result resource identifier.
|
||||||
*/
|
*/
|
||||||
$id = @ibase_query($this->connection,
|
$id = @ibase_query(
|
||||||
"SELECT * FROM $result WHERE 1=0");
|
$this->connection,
|
||||||
|
"SELECT * FROM $result WHERE 1=0"
|
||||||
|
);
|
||||||
$got_string = true;
|
$got_string = true;
|
||||||
} elseif (isset($result->result)) {
|
} elseif (isset($result->result)) {
|
||||||
/*
|
/*
|
||||||
@ -1053,7 +1065,7 @@ class DB_ibase extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'tables':
|
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
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -59,13 +59,13 @@ class DB_ifx extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'ifx';
|
public $phptype = 'ifx';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'ifx';
|
public $dbsyntax = 'ifx';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -80,7 +80,7 @@ class DB_ifx extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => 'emulate',
|
'limit' => 'emulate',
|
||||||
'new_link' => false,
|
'new_link' => false,
|
||||||
'numrows' => 'emulate',
|
'numrows' => 'emulate',
|
||||||
@ -94,7 +94,7 @@ class DB_ifx extends DB_common
|
|||||||
* A mapping of native error codes to DB error codes
|
* A mapping of native error codes to DB error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
'-201' => DB_ERROR_SYNTAX,
|
'-201' => DB_ERROR_SYNTAX,
|
||||||
'-206' => DB_ERROR_NOSUCHTABLE,
|
'-206' => DB_ERROR_NOSUCHTABLE,
|
||||||
'-217' => DB_ERROR_NOSUCHFIELD,
|
'-217' => DB_ERROR_NOSUCHFIELD,
|
||||||
@ -128,13 +128,13 @@ class DB_ifx extends DB_common
|
|||||||
* The raw database connection created by PHP
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,7 +142,7 @@ class DB_ifx extends DB_common
|
|||||||
* @var bool
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $autocommit = true;
|
public $autocommit = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The quantity of transactions begun
|
* The quantity of transactions begun
|
||||||
@ -153,14 +153,14 @@ class DB_ifx extends DB_common
|
|||||||
* @var integer
|
* @var integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $transaction_opcount = 0;
|
public $transaction_opcount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of rows affected by a data manipulation query
|
* The number of rows affected by a data manipulation query
|
||||||
* @var integer
|
* @var integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $affected = 0;
|
public $affected = 0;
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -171,7 +171,7 @@ class DB_ifx extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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') &&
|
if (!PEAR::loadExtension('informix') &&
|
||||||
!PEAR::loadExtension('Informix'))
|
!PEAR::loadExtension('Informix')) {
|
||||||
{
|
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
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
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$ret = @ifx_close($this->connection);
|
$ret = @ifx_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -243,7 +242,7 @@ class DB_ifx extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$ismanip = $this->_checkManip($query);
|
$ismanip = $this->_checkManip($query);
|
||||||
$this->last_query = $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
|
* @return true if a result is available otherwise return false
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -309,7 +308,7 @@ class DB_ifx extends DB_common
|
|||||||
*
|
*
|
||||||
* @return int the number of rows. A DB_Error object on failure.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
if ($this->_last_query_manip) {
|
if ($this->_last_query_manip) {
|
||||||
return $this->affected;
|
return $this->affected;
|
||||||
@ -341,7 +340,7 @@ class DB_ifx extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
if (($rownum !== null) && ($rownum < 0)) {
|
if (($rownum !== null) && ($rownum < 0)) {
|
||||||
return null;
|
return null;
|
||||||
@ -367,8 +366,7 @@ class DB_ifx extends DB_common
|
|||||||
}
|
}
|
||||||
$arr = $order;
|
$arr = $order;
|
||||||
} elseif ($fetchmode == DB_FETCHMODE_ASSOC &&
|
} 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);
|
$arr = array_change_key_case($arr, CASE_LOWER);
|
||||||
}
|
}
|
||||||
if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
|
if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
|
||||||
@ -396,7 +394,7 @@ class DB_ifx extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
if (!$cols = @ifx_num_fields($result)) {
|
if (!$cols = @ifx_num_fields($result)) {
|
||||||
return $this->ifxRaiseError();
|
return $this->ifxRaiseError();
|
||||||
@ -420,7 +418,7 @@ class DB_ifx extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
return is_resource($result) ? ifx_free_result($result) : false;
|
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
|
* @return int DB_OK on success. A DB_Error object if the driver
|
||||||
* doesn't support auto-committing transactions.
|
* doesn't support auto-committing transactions.
|
||||||
*/
|
*/
|
||||||
function autoCommit($onoff = true)
|
public function autoCommit($onoff = true)
|
||||||
{
|
{
|
||||||
// XXX if $this->transaction_opcount > 0, we should probably
|
// XXX if $this->transaction_opcount > 0, we should probably
|
||||||
// issue a warning here.
|
// 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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
$result = @ifx_query('COMMIT WORK', $this->connection);
|
$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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
$result = @ifx_query('ROLLBACK WORK', $this->connection);
|
$result = @ifx_query('ROLLBACK WORK', $this->connection);
|
||||||
@ -499,13 +497,18 @@ class DB_ifx extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_ifx::errorNative(), DB_ifx::errorCode()
|
* DB_ifx::errorNative(), DB_ifx::errorCode()
|
||||||
*/
|
*/
|
||||||
function ifxRaiseError($errno = null)
|
public function ifxRaiseError($errno = null)
|
||||||
{
|
{
|
||||||
if ($errno === null) {
|
if ($errno === null) {
|
||||||
$errno = $this->errorCode(ifx_error());
|
$errno = $this->errorCode(ifx_error());
|
||||||
}
|
}
|
||||||
return $this->raiseError($errno, null, null, null,
|
return $this->raiseError(
|
||||||
$this->errorNative());
|
$errno,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$this->errorNative()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -516,7 +519,7 @@ class DB_ifx extends DB_common
|
|||||||
*
|
*
|
||||||
* @return string the DBMS' error code and message
|
* @return string the DBMS' error code and message
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
return @ifx_error() . ' ' . @ifx_errormsg();
|
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
|
* @return int a portable DB error code, or DB_ERROR if this DB
|
||||||
* implementation has no mapping for the given error code.
|
* implementation has no mapping for the given error code.
|
||||||
*/
|
*/
|
||||||
function errorCode($nativecode)
|
public function errorCode($nativecode)
|
||||||
{
|
{
|
||||||
if (preg_match('/SQLCODE=(.*)]/', $nativecode, $match)) {
|
if (preg_match('/SQLCODE=(.*)]/', $nativecode, $match)) {
|
||||||
$code = $match[1];
|
$code = $match[1];
|
||||||
@ -570,15 +573,17 @@ class DB_ifx extends DB_common
|
|||||||
* @see DB_common::tableInfo()
|
* @see DB_common::tableInfo()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if (is_string($result)) {
|
if (is_string($result)) {
|
||||||
/*
|
/*
|
||||||
* Probably received a table name.
|
* Probably received a table name.
|
||||||
* Create a result resource identifier.
|
* Create a result resource identifier.
|
||||||
*/
|
*/
|
||||||
$id = @ifx_query("SELECT * FROM $result WHERE 1=0",
|
$id = @ifx_query(
|
||||||
$this->connection);
|
"SELECT * FROM $result WHERE 1=0",
|
||||||
|
$this->connection
|
||||||
|
);
|
||||||
$got_string = true;
|
$got_string = true;
|
||||||
} elseif (isset($result->result)) {
|
} elseif (isset($result->result)) {
|
||||||
/*
|
/*
|
||||||
@ -659,7 +664,7 @@ class DB_ifx extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'tables':
|
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
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -59,13 +59,13 @@ class DB_msql extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'msql';
|
public $phptype = 'msql';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'msql';
|
public $dbsyntax = 'msql';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -80,7 +80,7 @@ class DB_msql extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => 'emulate',
|
'limit' => 'emulate',
|
||||||
'new_link' => false,
|
'new_link' => false,
|
||||||
'numrows' => true,
|
'numrows' => true,
|
||||||
@ -94,20 +94,20 @@ class DB_msql extends DB_common
|
|||||||
* A mapping of native error codes to DB error codes
|
* A mapping of native error codes to DB error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The raw database connection created by PHP
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,7 +119,7 @@ class DB_msql extends DB_common
|
|||||||
* @var resource
|
* @var resource
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_result;
|
public $_result;
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -130,7 +130,7 @@ class DB_msql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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')) {
|
if (!PEAR::loadExtension('msql')) {
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||||
@ -187,24 +187,36 @@ class DB_msql extends DB_common
|
|||||||
$ini = ini_get('track_errors');
|
$ini = ini_get('track_errors');
|
||||||
$php_errormsg = '';
|
$php_errormsg = '';
|
||||||
if ($ini) {
|
if ($ini) {
|
||||||
$this->connection = @call_user_func_array($connect_function,
|
$this->connection = @call_user_func_array(
|
||||||
$params);
|
$connect_function,
|
||||||
|
$params
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
@ini_set('track_errors', 1);
|
@ini_set('track_errors', 1);
|
||||||
$this->connection = @call_user_func_array($connect_function,
|
$this->connection = @call_user_func_array(
|
||||||
$params);
|
$connect_function,
|
||||||
|
$params
|
||||||
|
);
|
||||||
@ini_set('track_errors', $ini);
|
@ini_set('track_errors', $ini);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->connection) {
|
if (!$this->connection) {
|
||||||
if (($err = @msql_error()) != '') {
|
if (($err = @msql_error()) != '') {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$err);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$err
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$php_errormsg);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$php_errormsg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +234,7 @@ class DB_msql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return bool TRUE on success, FALSE on failure
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$ret = @msql_close($this->connection);
|
$ret = @msql_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -241,7 +253,7 @@ class DB_msql extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$this->last_query = $query;
|
$this->last_query = $query;
|
||||||
$query = $this->modifyQuery($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
|
* @return true if a result is available otherwise return false
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -305,7 +317,7 @@ class DB_msql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
if ($rownum !== null) {
|
if ($rownum !== null) {
|
||||||
if (!@msql_data_seek($result, $rownum)) {
|
if (!@msql_data_seek($result, $rownum)) {
|
||||||
@ -348,7 +360,7 @@ class DB_msql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
return is_resource($result) ? msql_free_result($result) : false;
|
return is_resource($result) ? msql_free_result($result) : false;
|
||||||
}
|
}
|
||||||
@ -369,7 +381,7 @@ class DB_msql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
$cols = @msql_num_fields($result);
|
$cols = @msql_num_fields($result);
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
@ -394,7 +406,7 @@ class DB_msql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numRows()
|
* @see DB_result::numRows()
|
||||||
*/
|
*/
|
||||||
function numRows($result)
|
public function numRows($result)
|
||||||
{
|
{
|
||||||
$rows = @msql_num_rows($result);
|
$rows = @msql_num_rows($result);
|
||||||
if ($rows === false) {
|
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.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
if (!$this->_result) {
|
if (!$this->_result) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -437,7 +449,7 @@ class DB_msql extends DB_common
|
|||||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||||
* DB_msql::createSequence(), DB_msql::dropSequence()
|
* DB_msql::createSequence(), DB_msql::dropSequence()
|
||||||
*/
|
*/
|
||||||
function nextId($seq_name, $ondemand = true)
|
public function nextId($seq_name, $ondemand = true)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
$repeat = false;
|
$repeat = false;
|
||||||
@ -482,7 +494,7 @@ class DB_msql extends DB_common
|
|||||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_msql::nextID(), DB_msql::dropSequence()
|
* DB_msql::nextID(), DB_msql::dropSequence()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
$res = $this->query('CREATE TABLE ' . $seqname
|
$res = $this->query('CREATE TABLE ' . $seqname
|
||||||
@ -507,7 +519,7 @@ class DB_msql extends DB_common
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_msql::nextID(), DB_msql::createSequence()
|
* DB_msql::nextID(), DB_msql::createSequence()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('DROP TABLE ' . $this->getSequenceName($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()
|
* @see DB_common::quoteIdentifier()
|
||||||
* @since Method available since Release 1.7.0
|
* @since Method available since Release 1.7.0
|
||||||
*/
|
*/
|
||||||
function quoteIdentifier($str)
|
public function quoteIdentifier($str)
|
||||||
{
|
{
|
||||||
return $this->raiseError(DB_ERROR_UNSUPPORTED);
|
return $this->raiseError(DB_ERROR_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
@ -542,7 +554,8 @@ class DB_msql extends DB_common
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since release 1.7.8.
|
* @since Method available since release 1.7.8.
|
||||||
*/
|
*/
|
||||||
function quoteFloat($float) {
|
public function quoteFloat($float)
|
||||||
|
{
|
||||||
return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
|
return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,7 +572,7 @@ class DB_msql extends DB_common
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since Release 1.7.0
|
* @since Method available since Release 1.7.0
|
||||||
*/
|
*/
|
||||||
function escapeSimple($str)
|
public function escapeSimple($str)
|
||||||
{
|
{
|
||||||
return addslashes($str);
|
return addslashes($str);
|
||||||
}
|
}
|
||||||
@ -579,7 +592,7 @@ class DB_msql extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_msql::errorNative(), DB_msql::errorCode()
|
* DB_msql::errorNative(), DB_msql::errorCode()
|
||||||
*/
|
*/
|
||||||
function msqlRaiseError($errno = null)
|
public function msqlRaiseError($errno = null)
|
||||||
{
|
{
|
||||||
$native = $this->errorNative();
|
$native = $this->errorNative();
|
||||||
if ($errno === null) {
|
if ($errno === null) {
|
||||||
@ -596,7 +609,7 @@ class DB_msql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return string the DBMS' error message
|
* @return string the DBMS' error message
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
return @msql_error();
|
return @msql_error();
|
||||||
}
|
}
|
||||||
@ -611,7 +624,7 @@ class DB_msql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return integer the error number from a DB_ERROR* constant
|
* @return integer the error number from a DB_ERROR* constant
|
||||||
*/
|
*/
|
||||||
function errorCode($errormsg)
|
public function errorCode($errormsg)
|
||||||
{
|
{
|
||||||
static $error_regexps;
|
static $error_regexps;
|
||||||
|
|
||||||
@ -702,15 +715,17 @@ class DB_msql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_common::setOption()
|
* @see DB_common::setOption()
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if (is_string($result)) {
|
if (is_string($result)) {
|
||||||
/*
|
/*
|
||||||
* Probably received a table name.
|
* Probably received a table name.
|
||||||
* Create a result resource identifier.
|
* Create a result resource identifier.
|
||||||
*/
|
*/
|
||||||
$id = @msql_query("SELECT * FROM $result",
|
$id = @msql_query(
|
||||||
$this->connection);
|
"SELECT * FROM $result",
|
||||||
|
$this->connection
|
||||||
|
);
|
||||||
$got_string = true;
|
$got_string = true;
|
||||||
} elseif (isset($result->result)) {
|
} elseif (isset($result->result)) {
|
||||||
/*
|
/*
|
||||||
@ -794,15 +809,17 @@ class DB_msql extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'databases':
|
case 'databases':
|
||||||
$id = @msql_list_dbs($this->connection);
|
$id = @msql_list_dbs($this->connection);
|
||||||
break;
|
break;
|
||||||
case 'tables':
|
case 'tables':
|
||||||
$id = @msql_list_tables($this->dsn['database'],
|
$id = @msql_list_tables(
|
||||||
$this->connection);
|
$this->dsn['database'],
|
||||||
|
$this->connection
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
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
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -60,13 +60,13 @@ class DB_mssql extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'mssql';
|
public $phptype = 'mssql';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'mssql';
|
public $dbsyntax = 'mssql';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -81,7 +81,7 @@ class DB_mssql extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => 'emulate',
|
'limit' => 'emulate',
|
||||||
'new_link' => false,
|
'new_link' => false,
|
||||||
'numrows' => true,
|
'numrows' => true,
|
||||||
@ -96,7 +96,7 @@ class DB_mssql extends DB_common
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
// XXX Add here error codes ie: 'S100E' => DB_ERROR_SYNTAX
|
// XXX Add here error codes ie: 'S100E' => DB_ERROR_SYNTAX
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
102 => DB_ERROR_SYNTAX,
|
102 => DB_ERROR_SYNTAX,
|
||||||
110 => DB_ERROR_VALUE_COUNT_ON_ROW,
|
110 => DB_ERROR_VALUE_COUNT_ON_ROW,
|
||||||
155 => DB_ERROR_NOSUCHFIELD,
|
155 => DB_ERROR_NOSUCHFIELD,
|
||||||
@ -137,13 +137,13 @@ class DB_mssql extends DB_common
|
|||||||
* The raw database connection created by PHP
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,7 +151,7 @@ class DB_mssql extends DB_common
|
|||||||
* @var bool
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $autocommit = true;
|
public $autocommit = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The quantity of transactions begun
|
* The quantity of transactions begun
|
||||||
@ -162,7 +162,7 @@ class DB_mssql extends DB_common
|
|||||||
* @var integer
|
* @var integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $transaction_opcount = 0;
|
public $transaction_opcount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database specified in the DSN
|
* The database specified in the DSN
|
||||||
@ -172,7 +172,7 @@ class DB_mssql extends DB_common
|
|||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_db = null;
|
public $_db = null;
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -183,7 +183,7 @@ class DB_mssql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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')
|
if (!PEAR::loadExtension('mssql') && !PEAR::loadExtension('sybase')
|
||||||
&& !PEAR::loadExtension('sybase_ct'))
|
&& !PEAR::loadExtension('sybase_ct')) {
|
||||||
{
|
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
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);
|
$this->connection = @call_user_func_array($connect_function, $params);
|
||||||
|
|
||||||
if (!$this->connection) {
|
if (!$this->connection) {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
@mssql_get_last_message());
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
@mssql_get_last_message()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if ($dsn['database']) {
|
if ($dsn['database']) {
|
||||||
if (!@mssql_select_db($dsn['database'], $this->connection)) {
|
if (!@mssql_select_db($dsn['database'], $this->connection)) {
|
||||||
return $this->raiseError(DB_ERROR_NODBSELECTED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_NODBSELECTED,
|
||||||
@mssql_get_last_message());
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
@mssql_get_last_message()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->_db = $dsn['database'];
|
$this->_db = $dsn['database'];
|
||||||
}
|
}
|
||||||
@ -252,7 +259,7 @@ class DB_mssql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return bool TRUE on success, FALSE on failure
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$ret = @mssql_close($this->connection);
|
$ret = @mssql_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -271,7 +278,7 @@ class DB_mssql extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$ismanip = $this->_checkManip($query);
|
$ismanip = $this->_checkManip($query);
|
||||||
$this->last_query = $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
|
* @return true if a result is available otherwise return false
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return @mssql_next_result($result);
|
return @mssql_next_result($result);
|
||||||
}
|
}
|
||||||
@ -337,7 +344,7 @@ class DB_mssql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
if ($rownum !== null) {
|
if ($rownum !== null) {
|
||||||
if (!@mssql_data_seek($result, $rownum)) {
|
if (!@mssql_data_seek($result, $rownum)) {
|
||||||
@ -380,7 +387,7 @@ class DB_mssql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
return is_resource($result) ? mssql_free_result($result) : false;
|
return is_resource($result) ? mssql_free_result($result) : false;
|
||||||
}
|
}
|
||||||
@ -401,7 +408,7 @@ class DB_mssql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
$cols = @mssql_num_fields($result);
|
$cols = @mssql_num_fields($result);
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
@ -426,7 +433,7 @@ class DB_mssql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numRows()
|
* @see DB_result::numRows()
|
||||||
*/
|
*/
|
||||||
function numRows($result)
|
public function numRows($result)
|
||||||
{
|
{
|
||||||
$rows = @mssql_num_rows($result);
|
$rows = @mssql_num_rows($result);
|
||||||
if ($rows === false) {
|
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
|
* @return int DB_OK on success. A DB_Error object if the driver
|
||||||
* doesn't support auto-committing transactions.
|
* doesn't support auto-committing transactions.
|
||||||
*/
|
*/
|
||||||
function autoCommit($onoff = false)
|
public function autoCommit($onoff = false)
|
||||||
{
|
{
|
||||||
// XXX if $this->transaction_opcount > 0, we should probably
|
// XXX if $this->transaction_opcount > 0, we should probably
|
||||||
// issue a warning here.
|
// 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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
if (!@mssql_select_db($this->_db, $this->connection)) {
|
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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
if (!@mssql_select_db($this->_db, $this->connection)) {
|
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.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
if ($this->_last_query_manip) {
|
if ($this->_last_query_manip) {
|
||||||
$res = @mssql_query('select @@rowcount', $this->connection);
|
$res = @mssql_query('select @@rowcount', $this->connection);
|
||||||
@ -546,7 +553,7 @@ class DB_mssql extends DB_common
|
|||||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||||
* DB_mssql::createSequence(), DB_mssql::dropSequence()
|
* DB_mssql::createSequence(), DB_mssql::dropSequence()
|
||||||
*/
|
*/
|
||||||
function nextId($seq_name, $ondemand = true)
|
public function nextId($seq_name, $ondemand = true)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
if (!@mssql_select_db($this->_db, $this->connection)) {
|
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)");
|
$result = $this->query("INSERT INTO $seqname (vapor) VALUES (0)");
|
||||||
$this->popErrorHandling();
|
$this->popErrorHandling();
|
||||||
if ($ondemand && DB::isError($result) &&
|
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;
|
$repeat = 1;
|
||||||
$result = $this->createSequence($seq_name);
|
$result = $this->createSequence($seq_name);
|
||||||
if (DB::isError($result)) {
|
if (DB::isError($result)) {
|
||||||
@ -597,7 +603,7 @@ class DB_mssql extends DB_common
|
|||||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_mssql::nextID(), DB_mssql::dropSequence()
|
* DB_mssql::nextID(), DB_mssql::dropSequence()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('CREATE TABLE '
|
return $this->query('CREATE TABLE '
|
||||||
. $this->getSequenceName($seq_name)
|
. $this->getSequenceName($seq_name)
|
||||||
@ -618,7 +624,7 @@ class DB_mssql extends DB_common
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_mssql::nextID(), DB_mssql::createSequence()
|
* DB_mssql::nextID(), DB_mssql::createSequence()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('DROP TABLE ' . $this->getSequenceName($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()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function escapeSimple($str)
|
public function escapeSimple($str)
|
||||||
{
|
{
|
||||||
return str_replace(
|
return str_replace(
|
||||||
array("'", "\\\r\n", "\\\n"),
|
array("'", "\\\r\n", "\\\n"),
|
||||||
@ -657,7 +663,7 @@ class DB_mssql extends DB_common
|
|||||||
* @see DB_common::quoteIdentifier()
|
* @see DB_common::quoteIdentifier()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function quoteIdentifier($str)
|
public function quoteIdentifier($str)
|
||||||
{
|
{
|
||||||
return '[' . str_replace(']', ']]', $str) . ']';
|
return '[' . str_replace(']', ']]', $str) . ']';
|
||||||
}
|
}
|
||||||
@ -677,14 +683,19 @@ class DB_mssql extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_mssql::errorNative(), DB_mssql::errorCode()
|
* DB_mssql::errorNative(), DB_mssql::errorCode()
|
||||||
*/
|
*/
|
||||||
function mssqlRaiseError($code = null)
|
public function mssqlRaiseError($code = null)
|
||||||
{
|
{
|
||||||
$message = @mssql_get_last_message();
|
$message = @mssql_get_last_message();
|
||||||
if (!$code) {
|
if (!$code) {
|
||||||
$code = $this->errorNative();
|
$code = $this->errorNative();
|
||||||
}
|
}
|
||||||
return $this->raiseError($this->errorCode($code, $message),
|
return $this->raiseError(
|
||||||
null, null, null, "$code - $message");
|
$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
|
* @return int the DBMS' error code
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
$res = @mssql_query('select @@ERROR as ErrorCode', $this->connection);
|
$res = @mssql_query('select @@ERROR as ErrorCode', $this->connection);
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
@ -717,15 +728,14 @@ class DB_mssql extends DB_common
|
|||||||
* @return integer an error number from a DB error constant
|
* @return integer an error number from a DB error constant
|
||||||
* @see errorNative()
|
* @see errorNative()
|
||||||
*/
|
*/
|
||||||
function errorCode($nativecode = null, $msg = '')
|
public function errorCode($nativecode = null, $msg = '')
|
||||||
{
|
{
|
||||||
if (!$nativecode) {
|
if (!$nativecode) {
|
||||||
$nativecode = $this->errorNative();
|
$nativecode = $this->errorNative();
|
||||||
}
|
}
|
||||||
if (isset($this->errorcode_map[$nativecode])) {
|
if (isset($this->errorcode_map[$nativecode])) {
|
||||||
if ($nativecode == 3701
|
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 DB_ERROR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
return $this->errorcode_map[$nativecode];
|
return $this->errorcode_map[$nativecode];
|
||||||
@ -755,7 +765,7 @@ class DB_mssql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_common::tableInfo()
|
* @see DB_common::tableInfo()
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if (is_string($result)) {
|
if (is_string($result)) {
|
||||||
/*
|
/*
|
||||||
@ -765,8 +775,10 @@ class DB_mssql extends DB_common
|
|||||||
if (!@mssql_select_db($this->_db, $this->connection)) {
|
if (!@mssql_select_db($this->_db, $this->connection)) {
|
||||||
return $this->mssqlRaiseError(DB_ERROR_NODBSELECTED);
|
return $this->mssqlRaiseError(DB_ERROR_NODBSELECTED);
|
||||||
}
|
}
|
||||||
$id = @mssql_query("SELECT * FROM $result WHERE 1=0",
|
$id = @mssql_query(
|
||||||
$this->connection);
|
"SELECT * FROM $result WHERE 1=0",
|
||||||
|
$this->connection
|
||||||
|
);
|
||||||
$got_string = true;
|
$got_string = true;
|
||||||
} elseif (isset($result->result)) {
|
} elseif (isset($result->result)) {
|
||||||
/*
|
/*
|
||||||
@ -804,8 +816,10 @@ class DB_mssql extends DB_common
|
|||||||
|
|
||||||
for ($i = 0; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
if ($got_string) {
|
if ($got_string) {
|
||||||
$flags = $this->_mssql_field_flags($result,
|
$flags = $this->_mssql_field_flags(
|
||||||
@mssql_field_name($id, $i));
|
$result,
|
||||||
|
@mssql_field_name($id, $i)
|
||||||
|
);
|
||||||
if (DB::isError($flags)) {
|
if (DB::isError($flags)) {
|
||||||
return $flags;
|
return $flags;
|
||||||
}
|
}
|
||||||
@ -858,13 +872,12 @@ class DB_mssql extends DB_common
|
|||||||
* @access private
|
* @access private
|
||||||
* @author Joern Barthel <j_barthel@web.de>
|
* @author Joern Barthel <j_barthel@web.de>
|
||||||
*/
|
*/
|
||||||
function _mssql_field_flags($table, $column)
|
public function _mssql_field_flags($table, $column)
|
||||||
{
|
{
|
||||||
static $tableName = null;
|
static $tableName = null;
|
||||||
static $flags = array();
|
static $flags = array();
|
||||||
|
|
||||||
if ($table != $tableName) {
|
if ($table != $tableName) {
|
||||||
|
|
||||||
$flags = array();
|
$flags = array();
|
||||||
$tableName = $table;
|
$tableName = $table;
|
||||||
|
|
||||||
@ -935,7 +948,7 @@ class DB_mssql extends DB_common
|
|||||||
* @access private
|
* @access private
|
||||||
* @author Joern Barthel <j_barthel@web.de>
|
* @author Joern Barthel <j_barthel@web.de>
|
||||||
*/
|
*/
|
||||||
function _add_flag(&$array, $value)
|
public function _add_flag(&$array, $value)
|
||||||
{
|
{
|
||||||
if (!is_array($array)) {
|
if (!is_array($array)) {
|
||||||
$array = array($value);
|
$array = array($value);
|
||||||
@ -958,7 +971,7 @@ class DB_mssql extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'tables':
|
case 'tables':
|
||||||
@ -980,5 +993,3 @@ class DB_mssql extends DB_common
|
|||||||
* c-basic-offset: 4
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -52,13 +52,13 @@ class DB_mysql extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'mysql';
|
public $phptype = 'mysql';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'mysql';
|
public $dbsyntax = 'mysql';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -73,7 +73,7 @@ class DB_mysql extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => 'alter',
|
'limit' => 'alter',
|
||||||
'new_link' => '4.2.0',
|
'new_link' => '4.2.0',
|
||||||
'numrows' => true,
|
'numrows' => true,
|
||||||
@ -87,7 +87,7 @@ class DB_mysql extends DB_common
|
|||||||
* A mapping of native error codes to DB error codes
|
* A mapping of native error codes to DB error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
1004 => DB_ERROR_CANNOT_CREATE,
|
1004 => DB_ERROR_CANNOT_CREATE,
|
||||||
1005 => DB_ERROR_CANNOT_CREATE,
|
1005 => DB_ERROR_CANNOT_CREATE,
|
||||||
1006 => 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
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -134,7 +134,7 @@ class DB_mysql extends DB_common
|
|||||||
* @var bool
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $autocommit = true;
|
public $autocommit = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The quantity of transactions begun
|
* The quantity of transactions begun
|
||||||
@ -145,7 +145,7 @@ class DB_mysql extends DB_common
|
|||||||
* @var integer
|
* @var integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $transaction_opcount = 0;
|
public $transaction_opcount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database specified in the DSN
|
* The database specified in the DSN
|
||||||
@ -155,7 +155,7 @@ class DB_mysql extends DB_common
|
|||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_db = '';
|
public $_db = '';
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -166,7 +166,7 @@ class DB_mysql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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')) {
|
if (!PEAR::loadExtension('mysql')) {
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||||
@ -219,8 +219,7 @@ class DB_mysql extends DB_common
|
|||||||
|
|
||||||
if (!$persistent) {
|
if (!$persistent) {
|
||||||
if (isset($dsn['new_link'])
|
if (isset($dsn['new_link'])
|
||||||
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true))
|
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true)) {
|
||||||
{
|
|
||||||
$params[] = true;
|
$params[] = true;
|
||||||
} else {
|
} else {
|
||||||
$params[] = false;
|
$params[] = false;
|
||||||
@ -236,24 +235,36 @@ class DB_mysql extends DB_common
|
|||||||
$ini = ini_get('track_errors');
|
$ini = ini_get('track_errors');
|
||||||
$php_errormsg = '';
|
$php_errormsg = '';
|
||||||
if ($ini) {
|
if ($ini) {
|
||||||
$this->connection = @call_user_func_array($connect_function,
|
$this->connection = @call_user_func_array(
|
||||||
$params);
|
$connect_function,
|
||||||
|
$params
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
@ini_set('track_errors', 1);
|
@ini_set('track_errors', 1);
|
||||||
$this->connection = @call_user_func_array($connect_function,
|
$this->connection = @call_user_func_array(
|
||||||
$params);
|
$connect_function,
|
||||||
|
$params
|
||||||
|
);
|
||||||
@ini_set('track_errors', $ini);
|
@ini_set('track_errors', $ini);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->connection) {
|
if (!$this->connection) {
|
||||||
if (($err = @mysql_error()) != '') {
|
if (($err = @mysql_error()) != '') {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$err);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$err
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$php_errormsg);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$php_errormsg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +286,7 @@ class DB_mysql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return bool TRUE on success, FALSE on failure
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$ret = @mysql_close($this->connection);
|
$ret = @mysql_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -298,7 +309,7 @@ class DB_mysql extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$ismanip = $this->_checkManip($query);
|
$ismanip = $this->_checkManip($query);
|
||||||
$this->last_query = $query;
|
$this->last_query = $query;
|
||||||
@ -344,7 +355,7 @@ class DB_mysql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -372,7 +383,7 @@ class DB_mysql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
if ($rownum !== null) {
|
if ($rownum !== null) {
|
||||||
if (!@mysql_data_seek($result, $rownum)) {
|
if (!@mysql_data_seek($result, $rownum)) {
|
||||||
@ -420,7 +431,7 @@ class DB_mysql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
return is_resource($result) ? mysql_free_result($result) : false;
|
return is_resource($result) ? mysql_free_result($result) : false;
|
||||||
}
|
}
|
||||||
@ -441,7 +452,7 @@ class DB_mysql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
$cols = @mysql_num_fields($result);
|
$cols = @mysql_num_fields($result);
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
@ -466,7 +477,7 @@ class DB_mysql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numRows()
|
* @see DB_result::numRows()
|
||||||
*/
|
*/
|
||||||
function numRows($result)
|
public function numRows($result)
|
||||||
{
|
{
|
||||||
$rows = @mysql_num_rows($result);
|
$rows = @mysql_num_rows($result);
|
||||||
if ($rows === null) {
|
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
|
* @return int DB_OK on success. A DB_Error object if the driver
|
||||||
* doesn't support auto-committing transactions.
|
* doesn't support auto-committing transactions.
|
||||||
*/
|
*/
|
||||||
function autoCommit($onoff = false)
|
public function autoCommit($onoff = false)
|
||||||
{
|
{
|
||||||
// XXX if $this->transaction_opcount > 0, we should probably
|
// XXX if $this->transaction_opcount > 0, we should probably
|
||||||
// issue a warning here.
|
// 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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
if ($this->_db) {
|
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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
if ($this->_db) {
|
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.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
if ($this->_last_query_manip) {
|
if ($this->_last_query_manip) {
|
||||||
return @mysql_affected_rows($this->connection);
|
return @mysql_affected_rows($this->connection);
|
||||||
@ -581,7 +592,7 @@ class DB_mysql extends DB_common
|
|||||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||||
* DB_mysql::createSequence(), DB_mysql::dropSequence()
|
* DB_mysql::createSequence(), DB_mysql::dropSequence()
|
||||||
*/
|
*/
|
||||||
function nextId($seq_name, $ondemand = true)
|
public function nextId($seq_name, $ondemand = true)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
do {
|
do {
|
||||||
@ -622,10 +633,8 @@ class DB_mysql extends DB_common
|
|||||||
}
|
}
|
||||||
// We know what the result will be, so no need to try again
|
// We know what the result will be, so no need to try again
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
} elseif ($ondemand && DB::isError($result) &&
|
} elseif ($ondemand && DB::isError($result) &&
|
||||||
$result->getCode() == DB_ERROR_NOSUCHTABLE)
|
$result->getCode() == DB_ERROR_NOSUCHTABLE) {
|
||||||
{
|
|
||||||
// ONDEMAND TABLE CREATION
|
// ONDEMAND TABLE CREATION
|
||||||
$result = $this->createSequence($seq_name);
|
$result = $this->createSequence($seq_name);
|
||||||
if (DB::isError($result)) {
|
if (DB::isError($result)) {
|
||||||
@ -633,10 +642,8 @@ class DB_mysql extends DB_common
|
|||||||
} else {
|
} else {
|
||||||
$repeat = 1;
|
$repeat = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (DB::isError($result) &&
|
} elseif (DB::isError($result) &&
|
||||||
$result->getCode() == DB_ERROR_ALREADY_EXISTS)
|
$result->getCode() == DB_ERROR_ALREADY_EXISTS) {
|
||||||
{
|
|
||||||
// BACKWARDS COMPAT
|
// BACKWARDS COMPAT
|
||||||
// see _BCsequence() comment
|
// see _BCsequence() comment
|
||||||
$result = $this->_BCsequence($seqname);
|
$result = $this->_BCsequence($seqname);
|
||||||
@ -663,7 +670,7 @@ class DB_mysql extends DB_common
|
|||||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_mysql::nextID(), DB_mysql::dropSequence()
|
* DB_mysql::nextID(), DB_mysql::dropSequence()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
$res = $this->query('CREATE TABLE ' . $seqname
|
$res = $this->query('CREATE TABLE ' . $seqname
|
||||||
@ -694,7 +701,7 @@ class DB_mysql extends DB_common
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_mysql::nextID(), DB_mysql::createSequence()
|
* DB_mysql::nextID(), DB_mysql::createSequence()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
|
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
|
||||||
}
|
}
|
||||||
@ -712,7 +719,7 @@ class DB_mysql extends DB_common
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _BCsequence($seqname)
|
public function _BCsequence($seqname)
|
||||||
{
|
{
|
||||||
// Obtain a user-level lock... this will release any previous
|
// Obtain a user-level lock... this will release any previous
|
||||||
// application locks, but unlike LOCK TABLES, it does not abort
|
// application locks, but unlike LOCK TABLES, it does not abort
|
||||||
@ -767,7 +774,7 @@ class DB_mysql extends DB_common
|
|||||||
* @see DB_common::quoteIdentifier()
|
* @see DB_common::quoteIdentifier()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function quoteIdentifier($str)
|
public function quoteIdentifier($str)
|
||||||
{
|
{
|
||||||
return '`' . str_replace('`', '``', $str) . '`';
|
return '`' . str_replace('`', '``', $str) . '`';
|
||||||
}
|
}
|
||||||
@ -785,7 +792,7 @@ class DB_mysql extends DB_common
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function escapeSimple($str)
|
public function escapeSimple($str)
|
||||||
{
|
{
|
||||||
if (function_exists('mysql_real_escape_string')) {
|
if (function_exists('mysql_real_escape_string')) {
|
||||||
return @mysql_real_escape_string($str, $this->connection);
|
return @mysql_real_escape_string($str, $this->connection);
|
||||||
@ -811,14 +818,17 @@ class DB_mysql extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::setOption()
|
* @see DB_common::setOption()
|
||||||
*/
|
*/
|
||||||
function modifyQuery($query)
|
public function modifyQuery($query)
|
||||||
{
|
{
|
||||||
if ($this->options['portability'] & DB_PORTABILITY_DELETE_COUNT) {
|
if ($this->options['portability'] & DB_PORTABILITY_DELETE_COUNT) {
|
||||||
// "DELETE FROM table" gives 0 affected rows in MySQL.
|
// "DELETE FROM table" gives 0 affected rows in MySQL.
|
||||||
// This little hack lets you know how many rows were deleted.
|
// This little hack lets you know how many rows were deleted.
|
||||||
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) {
|
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) {
|
||||||
$query = preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/',
|
$query = preg_replace(
|
||||||
'DELETE FROM \1 WHERE 1=1', $query);
|
'/^\s*DELETE\s+FROM\s+(\S+)\s*$/',
|
||||||
|
'DELETE FROM \1 WHERE 1=1',
|
||||||
|
$query
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $query;
|
return $query;
|
||||||
@ -843,7 +853,7 @@ class DB_mysql extends DB_common
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @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) {
|
if (DB::isManip($query) || $this->_next_query_manip) {
|
||||||
return $query . " LIMIT $count";
|
return $query . " LIMIT $count";
|
||||||
@ -867,7 +877,7 @@ class DB_mysql extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_mysql::errorNative(), DB_common::errorCode()
|
* DB_mysql::errorNative(), DB_common::errorCode()
|
||||||
*/
|
*/
|
||||||
function mysqlRaiseError($errno = null)
|
public function mysqlRaiseError($errno = null)
|
||||||
{
|
{
|
||||||
if ($errno === null) {
|
if ($errno === null) {
|
||||||
if ($this->options['portability'] & DB_PORTABILITY_ERRORS) {
|
if ($this->options['portability'] & DB_PORTABILITY_ERRORS) {
|
||||||
@ -882,9 +892,14 @@ class DB_mysql extends DB_common
|
|||||||
}
|
}
|
||||||
$errno = $this->errorCode(mysql_errno($this->connection));
|
$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_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
|
* @return int the DBMS' error code
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
return @mysql_errno($this->connection);
|
return @mysql_errno($this->connection);
|
||||||
}
|
}
|
||||||
@ -918,7 +933,7 @@ class DB_mysql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_common::tableInfo()
|
* @see DB_common::tableInfo()
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if (is_string($result)) {
|
if (is_string($result)) {
|
||||||
// Fix for bug #11580.
|
// Fix for bug #11580.
|
||||||
@ -932,8 +947,10 @@ class DB_mysql extends DB_common
|
|||||||
* Probably received a table name.
|
* Probably received a table name.
|
||||||
* Create a result resource identifier.
|
* Create a result resource identifier.
|
||||||
*/
|
*/
|
||||||
$id = @mysql_query("SELECT * FROM $result LIMIT 0",
|
$id = @mysql_query(
|
||||||
$this->connection);
|
"SELECT * FROM $result LIMIT 0",
|
||||||
|
$this->connection
|
||||||
|
);
|
||||||
$got_string = true;
|
$got_string = true;
|
||||||
} elseif (isset($result->result)) {
|
} elseif (isset($result->result)) {
|
||||||
/*
|
/*
|
||||||
@ -1006,7 +1023,7 @@ class DB_mysql extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'tables':
|
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
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -55,13 +55,13 @@ class DB_mysqli extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'mysqli';
|
public $phptype = 'mysqli';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'mysqli';
|
public $dbsyntax = 'mysqli';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -76,7 +76,7 @@ class DB_mysqli extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => 'alter',
|
'limit' => 'alter',
|
||||||
'new_link' => false,
|
'new_link' => false,
|
||||||
'numrows' => true,
|
'numrows' => true,
|
||||||
@ -90,7 +90,7 @@ class DB_mysqli extends DB_common
|
|||||||
* A mapping of native error codes to DB error codes
|
* A mapping of native error codes to DB error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
1004 => DB_ERROR_CANNOT_CREATE,
|
1004 => DB_ERROR_CANNOT_CREATE,
|
||||||
1005 => DB_ERROR_CANNOT_CREATE,
|
1005 => DB_ERROR_CANNOT_CREATE,
|
||||||
1006 => 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
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +137,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @var bool
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $autocommit = true;
|
public $autocommit = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The quantity of transactions begun
|
* The quantity of transactions begun
|
||||||
@ -148,7 +148,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @var integer
|
* @var integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $transaction_opcount = 0;
|
public $transaction_opcount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database specified in the DSN
|
* The database specified in the DSN
|
||||||
@ -158,7 +158,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_db = '';
|
public $_db = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array for converting MYSQLI_*_FLAG constants to text values
|
* Array for converting MYSQLI_*_FLAG constants to text values
|
||||||
@ -166,7 +166,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @access public
|
* @access public
|
||||||
* @since Property available since Release 1.6.5
|
* @since Property available since Release 1.6.5
|
||||||
*/
|
*/
|
||||||
var $mysqli_flags = array(
|
public $mysqli_flags = array(
|
||||||
MYSQLI_NOT_NULL_FLAG => 'not_null',
|
MYSQLI_NOT_NULL_FLAG => 'not_null',
|
||||||
MYSQLI_PRI_KEY_FLAG => 'primary_key',
|
MYSQLI_PRI_KEY_FLAG => 'primary_key',
|
||||||
MYSQLI_UNIQUE_KEY_FLAG => 'unique_key',
|
MYSQLI_UNIQUE_KEY_FLAG => 'unique_key',
|
||||||
@ -188,7 +188,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @access public
|
* @access public
|
||||||
* @since Property available since Release 1.6.5
|
* @since Property available since Release 1.6.5
|
||||||
*/
|
*/
|
||||||
var $mysqli_types = array(
|
public $mysqli_types = array(
|
||||||
MYSQLI_TYPE_DECIMAL => 'decimal',
|
MYSQLI_TYPE_DECIMAL => 'decimal',
|
||||||
MYSQLI_TYPE_TINY => 'tinyint',
|
MYSQLI_TYPE_TINY => 'tinyint',
|
||||||
MYSQLI_TYPE_SHORT => 'int',
|
MYSQLI_TYPE_SHORT => 'int',
|
||||||
@ -228,7 +228,7 @@ class DB_mysqli extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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')) {
|
if (!PEAR::loadExtension('mysqli')) {
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||||
@ -314,8 +314,8 @@ class DB_mysqli extends DB_common
|
|||||||
$dsn['password'],
|
$dsn['password'],
|
||||||
$dsn['database'],
|
$dsn['database'],
|
||||||
$dsn['port'],
|
$dsn['port'],
|
||||||
$dsn['socket']))
|
$dsn['socket']
|
||||||
{
|
)) {
|
||||||
$this->connection = $init;
|
$this->connection = $init;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -333,13 +333,21 @@ class DB_mysqli extends DB_common
|
|||||||
|
|
||||||
if (!$this->connection) {
|
if (!$this->connection) {
|
||||||
if (($err = @mysqli_connect_error()) != '') {
|
if (($err = @mysqli_connect_error()) != '') {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$err);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$err
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$php_errormsg);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$php_errormsg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +366,7 @@ class DB_mysqli extends DB_common
|
|||||||
*
|
*
|
||||||
* @return bool TRUE on success, FALSE on failure
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$ret = @mysqli_close($this->connection);
|
$ret = @mysqli_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -377,7 +385,7 @@ class DB_mysqli extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$ismanip = $this->_checkManip($query);
|
$ismanip = $this->_checkManip($query);
|
||||||
$this->last_query = $query;
|
$this->last_query = $query;
|
||||||
@ -419,7 +427,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @return false
|
* @return false
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -447,7 +455,7 @@ class DB_mysqli extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
if ($rownum !== null) {
|
if ($rownum !== null) {
|
||||||
if (!@mysqli_data_seek($result, $rownum)) {
|
if (!@mysqli_data_seek($result, $rownum)) {
|
||||||
@ -495,7 +503,7 @@ class DB_mysqli extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
if (! $result instanceof mysqli_result) {
|
if (! $result instanceof mysqli_result) {
|
||||||
return false;
|
return false;
|
||||||
@ -520,7 +528,7 @@ class DB_mysqli extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
$cols = @mysqli_num_fields($result);
|
$cols = @mysqli_num_fields($result);
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
@ -545,7 +553,7 @@ class DB_mysqli extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numRows()
|
* @see DB_result::numRows()
|
||||||
*/
|
*/
|
||||||
function numRows($result)
|
public function numRows($result)
|
||||||
{
|
{
|
||||||
$rows = @mysqli_num_rows($result);
|
$rows = @mysqli_num_rows($result);
|
||||||
if ($rows === null) {
|
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
|
* @return int DB_OK on success. A DB_Error object if the driver
|
||||||
* doesn't support auto-committing transactions.
|
* doesn't support auto-committing transactions.
|
||||||
*/
|
*/
|
||||||
function autoCommit($onoff = false)
|
public function autoCommit($onoff = false)
|
||||||
{
|
{
|
||||||
// XXX if $this->transaction_opcount > 0, we should probably
|
// XXX if $this->transaction_opcount > 0, we should probably
|
||||||
// issue a warning here.
|
// 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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
if ($this->_db) {
|
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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
if ($this->_db) {
|
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.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
if ($this->_last_query_manip) {
|
if ($this->_last_query_manip) {
|
||||||
return @mysqli_affected_rows($this->connection);
|
return @mysqli_affected_rows($this->connection);
|
||||||
@ -660,7 +668,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||||
* DB_mysqli::createSequence(), DB_mysqli::dropSequence()
|
* DB_mysqli::createSequence(), DB_mysqli::dropSequence()
|
||||||
*/
|
*/
|
||||||
function nextId($seq_name, $ondemand = true)
|
public function nextId($seq_name, $ondemand = true)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
do {
|
do {
|
||||||
@ -704,10 +712,8 @@ class DB_mysqli extends DB_common
|
|||||||
}
|
}
|
||||||
// We know what the result will be, so no need to try again
|
// We know what the result will be, so no need to try again
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
} elseif ($ondemand && DB::isError($result) &&
|
} elseif ($ondemand && DB::isError($result) &&
|
||||||
$result->getCode() == DB_ERROR_NOSUCHTABLE)
|
$result->getCode() == DB_ERROR_NOSUCHTABLE) {
|
||||||
{
|
|
||||||
// ONDEMAND TABLE CREATION
|
// ONDEMAND TABLE CREATION
|
||||||
$result = $this->createSequence($seq_name);
|
$result = $this->createSequence($seq_name);
|
||||||
|
|
||||||
@ -719,10 +725,8 @@ class DB_mysqli extends DB_common
|
|||||||
// First ID of a newly created sequence is 1
|
// First ID of a newly created sequence is 1
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (DB::isError($result) &&
|
} elseif (DB::isError($result) &&
|
||||||
$result->getCode() == DB_ERROR_ALREADY_EXISTS)
|
$result->getCode() == DB_ERROR_ALREADY_EXISTS) {
|
||||||
{
|
|
||||||
// BACKWARDS COMPAT
|
// BACKWARDS COMPAT
|
||||||
// see _BCsequence() comment
|
// see _BCsequence() comment
|
||||||
$result = $this->_BCsequence($seqname);
|
$result = $this->_BCsequence($seqname);
|
||||||
@ -746,7 +750,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_mysqli::nextID(), DB_mysqli::dropSequence()
|
* DB_mysqli::nextID(), DB_mysqli::dropSequence()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
$res = $this->query('CREATE TABLE ' . $seqname
|
$res = $this->query('CREATE TABLE ' . $seqname
|
||||||
@ -772,7 +776,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_mysql::nextID(), DB_mysql::createSequence()
|
* DB_mysql::nextID(), DB_mysql::createSequence()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
|
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
|
||||||
}
|
}
|
||||||
@ -790,7 +794,7 @@ class DB_mysqli extends DB_common
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _BCsequence($seqname)
|
public function _BCsequence($seqname)
|
||||||
{
|
{
|
||||||
// Obtain a user-level lock... this will release any previous
|
// Obtain a user-level lock... this will release any previous
|
||||||
// application locks, but unlike LOCK TABLES, it does not abort
|
// application locks, but unlike LOCK TABLES, it does not abort
|
||||||
@ -846,7 +850,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @see DB_common::quoteIdentifier()
|
* @see DB_common::quoteIdentifier()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function quoteIdentifier($str)
|
public function quoteIdentifier($str)
|
||||||
{
|
{
|
||||||
return '`' . str_replace('`', '``', $str) . '`';
|
return '`' . str_replace('`', '``', $str) . '`';
|
||||||
}
|
}
|
||||||
@ -864,7 +868,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function escapeSimple($str)
|
public function escapeSimple($str)
|
||||||
{
|
{
|
||||||
return @mysqli_real_escape_string($this->connection, $str);
|
return @mysqli_real_escape_string($this->connection, $str);
|
||||||
}
|
}
|
||||||
@ -888,7 +892,7 @@ class DB_mysqli extends DB_common
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @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) {
|
if (DB::isManip($query) || $this->_next_query_manip) {
|
||||||
return $query . " LIMIT $count";
|
return $query . " LIMIT $count";
|
||||||
@ -912,7 +916,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_mysqli::errorNative(), DB_common::errorCode()
|
* DB_mysqli::errorNative(), DB_common::errorCode()
|
||||||
*/
|
*/
|
||||||
function mysqliRaiseError($errno = null)
|
public function mysqliRaiseError($errno = null)
|
||||||
{
|
{
|
||||||
if ($errno === null) {
|
if ($errno === null) {
|
||||||
if ($this->options['portability'] & DB_PORTABILITY_ERRORS) {
|
if ($this->options['portability'] & DB_PORTABILITY_ERRORS) {
|
||||||
@ -927,9 +931,14 @@ class DB_mysqli extends DB_common
|
|||||||
}
|
}
|
||||||
$errno = $this->errorCode(mysqli_errno($this->connection));
|
$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_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
|
* @return int the DBMS' error code
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
return @mysqli_errno($this->connection);
|
return @mysqli_errno($this->connection);
|
||||||
}
|
}
|
||||||
@ -963,7 +972,7 @@ class DB_mysqli extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_common::setOption()
|
* @see DB_common::setOption()
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if (is_string($result)) {
|
if (is_string($result)) {
|
||||||
// Fix for bug #11580.
|
// Fix for bug #11580.
|
||||||
@ -977,8 +986,10 @@ class DB_mysqli extends DB_common
|
|||||||
* Probably received a table name.
|
* Probably received a table name.
|
||||||
* Create a result resource identifier.
|
* Create a result resource identifier.
|
||||||
*/
|
*/
|
||||||
$id = @mysqli_query($this->connection,
|
$id = @mysqli_query(
|
||||||
"SELECT * FROM $result LIMIT 0");
|
$this->connection,
|
||||||
|
"SELECT * FROM $result LIMIT 0"
|
||||||
|
);
|
||||||
$got_string = true;
|
$got_string = true;
|
||||||
} elseif (isset($result->result)) {
|
} elseif (isset($result->result)) {
|
||||||
/*
|
/*
|
||||||
@ -1072,7 +1083,7 @@ class DB_mysqli extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'tables':
|
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
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -58,13 +58,13 @@ class DB_oci8 extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'oci8';
|
public $phptype = 'oci8';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'oci8';
|
public $dbsyntax = 'oci8';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -79,7 +79,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => 'alter',
|
'limit' => 'alter',
|
||||||
'new_link' => '5.0.0',
|
'new_link' => '5.0.0',
|
||||||
'numrows' => 'subquery',
|
'numrows' => 'subquery',
|
||||||
@ -93,7 +93,7 @@ class DB_oci8 extends DB_common
|
|||||||
* A mapping of native error codes to DB error codes
|
* A mapping of native error codes to DB error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
1 => DB_ERROR_CONSTRAINT,
|
1 => DB_ERROR_CONSTRAINT,
|
||||||
900 => DB_ERROR_SYNTAX,
|
900 => DB_ERROR_SYNTAX,
|
||||||
904 => DB_ERROR_NOSUCHFIELD,
|
904 => DB_ERROR_NOSUCHFIELD,
|
||||||
@ -119,13 +119,13 @@ class DB_oci8 extends DB_common
|
|||||||
* The raw database connection created by PHP
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,7 +133,7 @@ class DB_oci8 extends DB_common
|
|||||||
* @var bool
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $autocommit = true;
|
public $autocommit = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the $data passed to execute() in the oci8 driver
|
* Stores the $data passed to execute() in the oci8 driver
|
||||||
@ -146,27 +146,27 @@ class DB_oci8 extends DB_common
|
|||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_data = array();
|
public $_data = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result or statement handle from the most recently executed query
|
* The result or statement handle from the most recently executed query
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $last_stmt;
|
public $last_stmt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the given prepared statement a data manipulation query?
|
* Is the given prepared statement a data manipulation query?
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $manip_query = array();
|
public $manip_query = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store of prepared SQL queries.
|
* Store of prepared SQL queries.
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_prepared_queries = array();
|
public $_prepared_queries = array();
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -177,7 +177,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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')) {
|
if (!PEAR::loadExtension('oci8')) {
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||||
@ -233,8 +233,7 @@ class DB_oci8 extends DB_common
|
|||||||
|
|
||||||
if (function_exists('oci_connect')) {
|
if (function_exists('oci_connect')) {
|
||||||
if (isset($dsn['new_link'])
|
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';
|
$connect_function = 'oci_new_connect';
|
||||||
} else {
|
} else {
|
||||||
$connect_function = $persistent ? 'oci_pconnect'
|
$connect_function = $persistent ? 'oci_pconnect'
|
||||||
@ -245,36 +244,48 @@ class DB_oci8 extends DB_common
|
|||||||
}
|
}
|
||||||
|
|
||||||
$char = empty($dsn['charset']) ? null : $dsn['charset'];
|
$char = empty($dsn['charset']) ? null : $dsn['charset'];
|
||||||
$this->connection = @$connect_function($dsn['username'],
|
$this->connection = @$connect_function(
|
||||||
|
$dsn['username'],
|
||||||
$dsn['password'],
|
$dsn['password'],
|
||||||
$db,
|
$db,
|
||||||
$char);
|
$char
|
||||||
|
);
|
||||||
$error = OCIError();
|
$error = OCIError();
|
||||||
if (!empty($error) && $error['code'] == 12541) {
|
if (!empty($error) && $error['code'] == 12541) {
|
||||||
// Couldn't find TNS listener. Try direct connection.
|
// Couldn't find TNS listener. Try direct connection.
|
||||||
$this->connection = @$connect_function($dsn['username'],
|
$this->connection = @$connect_function(
|
||||||
|
$dsn['username'],
|
||||||
$dsn['password'],
|
$dsn['password'],
|
||||||
null,
|
null,
|
||||||
$char);
|
$char
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$connect_function = $persistent ? 'OCIPLogon' : 'OCILogon';
|
$connect_function = $persistent ? 'OCIPLogon' : 'OCILogon';
|
||||||
if ($db) {
|
if ($db) {
|
||||||
$this->connection = @$connect_function($dsn['username'],
|
$this->connection = @$connect_function(
|
||||||
|
$dsn['username'],
|
||||||
$dsn['password'],
|
$dsn['password'],
|
||||||
$db);
|
$db
|
||||||
|
);
|
||||||
} elseif ($dsn['username'] || $dsn['password']) {
|
} elseif ($dsn['username'] || $dsn['password']) {
|
||||||
$this->connection = @$connect_function($dsn['username'],
|
$this->connection = @$connect_function(
|
||||||
$dsn['password']);
|
$dsn['username'],
|
||||||
|
$dsn['password']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->connection) {
|
if (!$this->connection) {
|
||||||
$error = OCIError();
|
$error = OCIError();
|
||||||
$error = (is_array($error)) ? $error['message'] : null;
|
$error = (is_array($error)) ? $error['message'] : null;
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$error);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$error
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return DB_OK;
|
return DB_OK;
|
||||||
}
|
}
|
||||||
@ -287,7 +298,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @return bool TRUE on success, FALSE on failure
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
if (function_exists('oci_close')) {
|
if (function_exists('oci_close')) {
|
||||||
$ret = @oci_close($this->connection);
|
$ret = @oci_close($this->connection);
|
||||||
@ -314,7 +325,7 @@ class DB_oci8 extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$this->_data = array();
|
$this->_data = array();
|
||||||
$this->last_parameters = array();
|
$this->last_parameters = array();
|
||||||
@ -353,7 +364,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @return true if a result is available otherwise return false
|
* @return true if a result is available otherwise return false
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -381,7 +392,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
if ($rownum !== null) {
|
if ($rownum !== null) {
|
||||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||||
@ -389,8 +400,7 @@ class DB_oci8 extends DB_common
|
|||||||
if ($fetchmode & DB_FETCHMODE_ASSOC) {
|
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 &&
|
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE &&
|
||||||
$moredata)
|
$moredata) {
|
||||||
{
|
|
||||||
$arr = array_change_key_case($arr, CASE_LOWER);
|
$arr = array_change_key_case($arr, CASE_LOWER);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -424,7 +434,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
return is_resource($result) ? OCIFreeStatement($result) : false;
|
return is_resource($result) ? OCIFreeStatement($result) : false;
|
||||||
}
|
}
|
||||||
@ -441,7 +451,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_oci8::prepare()
|
* @see DB_oci8::prepare()
|
||||||
*/
|
*/
|
||||||
function freePrepared($stmt, $free_resource = true)
|
public function freePrepared($stmt, $free_resource = true)
|
||||||
{
|
{
|
||||||
if (!is_resource($stmt)) {
|
if (!is_resource($stmt)) {
|
||||||
return false;
|
return false;
|
||||||
@ -478,12 +488,11 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numRows(), DB_common::setOption()
|
* @see DB_result::numRows(), DB_common::setOption()
|
||||||
*/
|
*/
|
||||||
function numRows($result)
|
public function numRows($result)
|
||||||
{
|
{
|
||||||
// emulate numRows for Oracle. yuck.
|
// emulate numRows for Oracle. yuck.
|
||||||
if ($this->options['portability'] & DB_PORTABILITY_NUMROWS &&
|
if ($this->options['portability'] & DB_PORTABILITY_NUMROWS &&
|
||||||
$result === $this->last_stmt)
|
$result === $this->last_stmt) {
|
||||||
{
|
|
||||||
$countquery = 'SELECT COUNT(*) FROM ('.$this->last_query.')';
|
$countquery = 'SELECT COUNT(*) FROM ('.$this->last_query.')';
|
||||||
$save_query = $this->last_query;
|
$save_query = $this->last_query;
|
||||||
$save_stmt = $this->last_stmt;
|
$save_stmt = $this->last_stmt;
|
||||||
@ -495,8 +504,7 @@ class DB_oci8 extends DB_common
|
|||||||
$this->last_stmt = $save_stmt;
|
$this->last_stmt = $save_stmt;
|
||||||
|
|
||||||
if (DB::isError($count) ||
|
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);
|
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,7 +529,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
$cols = @OCINumCols($result);
|
$cols = @OCINumCols($result);
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
@ -560,10 +568,14 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_oci8::execute()
|
* @see DB_oci8::execute()
|
||||||
*/
|
*/
|
||||||
function prepare($query)
|
public function prepare($query)
|
||||||
{
|
{
|
||||||
$tokens = preg_split('/((?<!\\\)[&?!])/', $query, -1,
|
$tokens = preg_split(
|
||||||
PREG_SPLIT_DELIM_CAPTURE);
|
'/((?<!\\\)[&?!])/',
|
||||||
|
$query,
|
||||||
|
-1,
|
||||||
|
PREG_SPLIT_DELIM_CAPTURE
|
||||||
|
);
|
||||||
$binds = count($tokens) - 1;
|
$binds = count($tokens) - 1;
|
||||||
$token = 0;
|
$token = 0;
|
||||||
$types = array();
|
$types = array();
|
||||||
@ -627,7 +639,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_oci8::prepare()
|
* @see DB_oci8::prepare()
|
||||||
*/
|
*/
|
||||||
function &execute($stmt, $data = array())
|
public function &execute($stmt, $data = array())
|
||||||
{
|
{
|
||||||
$data = (array)$data;
|
$data = (array)$data;
|
||||||
$this->last_parameters = $data;
|
$this->last_parameters = $data;
|
||||||
@ -671,8 +683,12 @@ class DB_oci8 extends DB_common
|
|||||||
$tmp = $this->oci8RaiseError($stmt);
|
$tmp = $this->oci8RaiseError($stmt);
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
$this->last_query = preg_replace("/:bind$i(?!\d)/",
|
$this->last_query = preg_replace(
|
||||||
$this->quoteSmart($data[$key]), $this->last_query, 1);
|
"/:bind$i(?!\d)/",
|
||||||
|
$this->quoteSmart($data[$key]),
|
||||||
|
$this->last_query,
|
||||||
|
1
|
||||||
|
);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
if ($this->autocommit) {
|
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
|
* @return int DB_OK on success. A DB_Error object if the driver
|
||||||
* doesn't support auto-committing transactions.
|
* 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;
|
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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
$result = @OCICommit($this->connection);
|
$result = @OCICommit($this->connection);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -739,7 +756,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @return int DB_OK on success. A DB_Error object on failure.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
$result = @OCIRollback($this->connection);
|
$result = @OCIRollback($this->connection);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -758,7 +775,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @return int the number of rows. A DB_Error object on failure.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
if ($this->last_stmt === false) {
|
if ($this->last_stmt === false) {
|
||||||
return $this->oci8RaiseError();
|
return $this->oci8RaiseError();
|
||||||
@ -784,7 +801,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function modifyQuery($query)
|
public function modifyQuery($query)
|
||||||
{
|
{
|
||||||
if (preg_match('/^\s*SELECT/i', $query) &&
|
if (preg_match('/^\s*SELECT/i', $query) &&
|
||||||
!preg_match('/\sFROM\s/i', $query)) {
|
!preg_match('/\sFROM\s/i', $query)) {
|
||||||
@ -812,7 +829,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @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
|
// Let Oracle return the name of the columns instead of
|
||||||
// coding a "home" SQL parser
|
// coding a "home" SQL parser
|
||||||
@ -874,7 +891,7 @@ class DB_oci8 extends DB_common
|
|||||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||||
* DB_oci8::createSequence(), DB_oci8::dropSequence()
|
* DB_oci8::createSequence(), DB_oci8::dropSequence()
|
||||||
*/
|
*/
|
||||||
function nextId($seq_name, $ondemand = true)
|
public function nextId($seq_name, $ondemand = true)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
$repeat = 0;
|
$repeat = 0;
|
||||||
@ -910,7 +927,7 @@ class DB_oci8 extends DB_common
|
|||||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_oci8::nextID(), DB_oci8::dropSequence()
|
* DB_oci8::nextID(), DB_oci8::dropSequence()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('CREATE SEQUENCE '
|
return $this->query('CREATE SEQUENCE '
|
||||||
. $this->getSequenceName($seq_name));
|
. $this->getSequenceName($seq_name));
|
||||||
@ -929,7 +946,7 @@ class DB_oci8 extends DB_common
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_oci8::nextID(), DB_oci8::createSequence()
|
* DB_oci8::nextID(), DB_oci8::createSequence()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('DROP SEQUENCE '
|
return $this->query('DROP SEQUENCE '
|
||||||
. $this->getSequenceName($seq_name));
|
. $this->getSequenceName($seq_name));
|
||||||
@ -950,16 +967,26 @@ class DB_oci8 extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_oci8::errorNative(), DB_oci8::errorCode()
|
* DB_oci8::errorNative(), DB_oci8::errorCode()
|
||||||
*/
|
*/
|
||||||
function oci8RaiseError($errno = null)
|
public function oci8RaiseError($errno = null)
|
||||||
{
|
{
|
||||||
if ($errno === null) {
|
if ($errno === null) {
|
||||||
$error = @OCIError($this->connection);
|
$error = @OCIError($this->connection);
|
||||||
return $this->raiseError($this->errorCode($error['code']),
|
return $this->raiseError(
|
||||||
null, null, null, $error['message']);
|
$this->errorCode($error['code']),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$error['message']
|
||||||
|
);
|
||||||
} elseif (is_resource($errno)) {
|
} elseif (is_resource($errno)) {
|
||||||
$error = @OCIError($errno);
|
$error = @OCIError($errno);
|
||||||
return $this->raiseError($this->errorCode($error['code']),
|
return $this->raiseError(
|
||||||
null, null, null, $error['message']);
|
$this->errorCode($error['code']),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$error['message']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $this->raiseError($this->errorCode($errno));
|
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
|
* @return int the DBMS' error code. FALSE if the code could not be
|
||||||
* determined
|
* determined
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
if (is_resource($this->last_stmt)) {
|
if (is_resource($this->last_stmt)) {
|
||||||
$error = @OCIError($this->last_stmt);
|
$error = @OCIError($this->last_stmt);
|
||||||
@ -1009,7 +1036,7 @@ class DB_oci8 extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_common::tableInfo()
|
* @see DB_common::tableInfo()
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
|
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
|
||||||
$case_func = 'strtolower';
|
$case_func = 'strtolower';
|
||||||
@ -1061,7 +1088,6 @@ class DB_oci8 extends DB_common
|
|||||||
$res['num_fields'] = $i;
|
$res['num_fields'] = $i;
|
||||||
}
|
}
|
||||||
@OCIFreeStatement($stmt);
|
@OCIFreeStatement($stmt);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (isset($result->result)) {
|
if (isset($result->result)) {
|
||||||
/*
|
/*
|
||||||
@ -1114,7 +1140,7 @@ class DB_oci8 extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'tables':
|
case 'tables':
|
||||||
@ -1140,12 +1166,12 @@ class DB_oci8 extends DB_common
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since release 1.7.8.
|
* @since Method available since release 1.7.8.
|
||||||
*/
|
*/
|
||||||
function quoteFloat($float) {
|
public function quoteFloat($float)
|
||||||
|
{
|
||||||
return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
|
return $this->escapeSimple(str_replace(',', '.', strval(floatval($float))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1154,5 +1180,3 @@ class DB_oci8 extends DB_common
|
|||||||
* c-basic-offset: 4
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -55,13 +55,13 @@ class DB_odbc extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'odbc';
|
public $phptype = 'odbc';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'sql92';
|
public $dbsyntax = 'sql92';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -81,7 +81,7 @@ class DB_odbc extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => 'emulate',
|
'limit' => 'emulate',
|
||||||
'new_link' => false,
|
'new_link' => false,
|
||||||
'numrows' => true,
|
'numrows' => true,
|
||||||
@ -95,7 +95,7 @@ class DB_odbc extends DB_common
|
|||||||
* A mapping of native error codes to DB error codes
|
* A mapping of native error codes to DB error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
'01004' => DB_ERROR_TRUNCATED,
|
'01004' => DB_ERROR_TRUNCATED,
|
||||||
'07001' => DB_ERROR_MISMATCH,
|
'07001' => DB_ERROR_MISMATCH,
|
||||||
'21S01' => DB_ERROR_VALUE_COUNT_ON_ROW,
|
'21S01' => DB_ERROR_VALUE_COUNT_ON_ROW,
|
||||||
@ -132,13 +132,13 @@ class DB_odbc extends DB_common
|
|||||||
* The raw database connection created by PHP
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,7 +146,7 @@ class DB_odbc extends DB_common
|
|||||||
* @var integer
|
* @var integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $affected = 0;
|
public $affected = 0;
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -157,7 +157,7 @@ class DB_odbc extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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')) {
|
if (!PEAR::loadExtension('odbc')) {
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
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';
|
$connect_function = $persistent ? 'odbc_pconnect' : 'odbc_connect';
|
||||||
|
|
||||||
if (empty($dsn['cursor'])) {
|
if (empty($dsn['cursor'])) {
|
||||||
$this->connection = @$connect_function($odbcdsn, $dsn['username'],
|
$this->connection = @$connect_function(
|
||||||
$dsn['password']);
|
$odbcdsn,
|
||||||
|
$dsn['username'],
|
||||||
|
$dsn['password']
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->connection = @$connect_function($odbcdsn, $dsn['username'],
|
$this->connection = @$connect_function(
|
||||||
|
$odbcdsn,
|
||||||
|
$dsn['username'],
|
||||||
$dsn['password'],
|
$dsn['password'],
|
||||||
$dsn['cursor']);
|
$dsn['cursor']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_resource($this->connection)) {
|
if (!is_resource($this->connection)) {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$this->errorNative());
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$this->errorNative()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return DB_OK;
|
return DB_OK;
|
||||||
}
|
}
|
||||||
@ -237,7 +247,7 @@ class DB_odbc extends DB_common
|
|||||||
*
|
*
|
||||||
* @return bool TRUE on success, FALSE on failure
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$err = @odbc_close($this->connection);
|
$err = @odbc_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -256,7 +266,7 @@ class DB_odbc extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$this->last_query = $query;
|
$this->last_query = $query;
|
||||||
$query = $this->modifyQuery($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
|
* @return true if a result is available otherwise return false
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return @odbc_next_result($result);
|
return @odbc_next_result($result);
|
||||||
}
|
}
|
||||||
@ -314,7 +324,7 @@ class DB_odbc extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
$arr = array();
|
$arr = array();
|
||||||
if ($rownum !== null) {
|
if ($rownum !== null) {
|
||||||
@ -365,7 +375,7 @@ class DB_odbc extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
return is_resource($result) ? odbc_free_result($result) : false;
|
return is_resource($result) ? odbc_free_result($result) : false;
|
||||||
}
|
}
|
||||||
@ -386,7 +396,7 @@ class DB_odbc extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
$cols = @odbc_num_fields($result);
|
$cols = @odbc_num_fields($result);
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
@ -405,7 +415,7 @@ class DB_odbc extends DB_common
|
|||||||
*
|
*
|
||||||
* @return int the number of rows. A DB_Error object on failure.
|
* @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
|
if (empty($this->affected)) { // In case of SELECT stms
|
||||||
return 0;
|
return 0;
|
||||||
@ -436,7 +446,7 @@ class DB_odbc extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numRows()
|
* @see DB_result::numRows()
|
||||||
*/
|
*/
|
||||||
function numRows($result)
|
public function numRows($result)
|
||||||
{
|
{
|
||||||
$nrows = @odbc_num_rows($result);
|
$nrows = @odbc_num_rows($result);
|
||||||
if ($nrows == -1) {
|
if ($nrows == -1) {
|
||||||
@ -464,7 +474,7 @@ class DB_odbc extends DB_common
|
|||||||
* @see DB_common::quoteIdentifier()
|
* @see DB_common::quoteIdentifier()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function quoteIdentifier($str)
|
public function quoteIdentifier($str)
|
||||||
{
|
{
|
||||||
switch ($this->dsn['dbsyntax']) {
|
switch ($this->dsn['dbsyntax']) {
|
||||||
case 'access':
|
case 'access':
|
||||||
@ -496,7 +506,7 @@ class DB_odbc extends DB_common
|
|||||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||||
* DB_odbc::createSequence(), DB_odbc::dropSequence()
|
* DB_odbc::createSequence(), DB_odbc::dropSequence()
|
||||||
*/
|
*/
|
||||||
function nextId($seq_name, $ondemand = true)
|
public function nextId($seq_name, $ondemand = true)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
$repeat = 0;
|
$repeat = 0;
|
||||||
@ -546,7 +556,7 @@ class DB_odbc extends DB_common
|
|||||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_odbc::nextID(), DB_odbc::dropSequence()
|
* DB_odbc::nextID(), DB_odbc::dropSequence()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('CREATE TABLE '
|
return $this->query('CREATE TABLE '
|
||||||
. $this->getSequenceName($seq_name)
|
. $this->getSequenceName($seq_name)
|
||||||
@ -567,7 +577,7 @@ class DB_odbc extends DB_common
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_odbc::nextID(), DB_odbc::createSequence()
|
* DB_odbc::nextID(), DB_odbc::createSequence()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('DROP TABLE ' . $this->getSequenceName($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
|
* @return int DB_OK on success. A DB_Error object if the driver
|
||||||
* doesn't support auto-committing transactions.
|
* doesn't support auto-committing transactions.
|
||||||
*/
|
*/
|
||||||
function autoCommit($onoff = false)
|
public function autoCommit($onoff = false)
|
||||||
{
|
{
|
||||||
if (!@odbc_autocommit($this->connection, $onoff)) {
|
if (!@odbc_autocommit($this->connection, $onoff)) {
|
||||||
return $this->odbcRaiseError();
|
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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
if (!@odbc_commit($this->connection)) {
|
if (!@odbc_commit($this->connection)) {
|
||||||
return $this->odbcRaiseError();
|
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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
if (!@odbc_rollback($this->connection)) {
|
if (!@odbc_rollback($this->connection)) {
|
||||||
return $this->odbcRaiseError();
|
return $this->odbcRaiseError();
|
||||||
@ -638,7 +648,7 @@ class DB_odbc extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_odbc::errorNative(), DB_common::errorCode()
|
* DB_odbc::errorNative(), DB_common::errorCode()
|
||||||
*/
|
*/
|
||||||
function odbcRaiseError($errno = null)
|
public function odbcRaiseError($errno = null)
|
||||||
{
|
{
|
||||||
if ($errno === null) {
|
if ($errno === null) {
|
||||||
switch ($this->dbsyntax) {
|
switch ($this->dbsyntax) {
|
||||||
@ -664,9 +674,13 @@ class DB_odbc extends DB_common
|
|||||||
}
|
}
|
||||||
foreach ($error_regexps as $regexp => $code) {
|
foreach ($error_regexps as $regexp => $code) {
|
||||||
if (preg_match($regexp, $errormsg)) {
|
if (preg_match($regexp, $errormsg)) {
|
||||||
return $this->raiseError($code,
|
return $this->raiseError(
|
||||||
null, null, null,
|
$code,
|
||||||
$native_code . ' ' . $errormsg);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$native_code . ' ' . $errormsg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$errno = DB_ERROR;
|
$errno = DB_ERROR;
|
||||||
@ -678,8 +692,13 @@ class DB_odbc extends DB_common
|
|||||||
$errno = $this->errorCode(odbc_error($this->connection));
|
$errno = $this->errorCode(odbc_error($this->connection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->raiseError($errno, null, null, null,
|
return $this->raiseError(
|
||||||
$this->errorNative());
|
$errno,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$this->errorNative()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -690,7 +709,7 @@ class DB_odbc extends DB_common
|
|||||||
*
|
*
|
||||||
* @return string the DBMS' error code and message
|
* @return string the DBMS' error code and message
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
if (!is_resource($this->connection)) {
|
if (!is_resource($this->connection)) {
|
||||||
return @odbc_error() . ' ' . @odbc_errormsg();
|
return @odbc_error() . ' ' . @odbc_errormsg();
|
||||||
@ -717,7 +736,7 @@ class DB_odbc extends DB_common
|
|||||||
* @see DB_common::tableInfo()
|
* @see DB_common::tableInfo()
|
||||||
* @since Method available since Release 1.7.0
|
* @since Method available since Release 1.7.0
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if (is_string($result)) {
|
if (is_string($result)) {
|
||||||
/*
|
/*
|
||||||
@ -803,7 +822,7 @@ class DB_odbc extends DB_common
|
|||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
* @since Method available since Release 1.7.0
|
* @since Method available since Release 1.7.0
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'databases':
|
case 'databases':
|
||||||
@ -813,9 +832,10 @@ class DB_odbc extends DB_common
|
|||||||
$res = @odbc_data_source($this->connection, SQL_FETCH_FIRST);
|
$res = @odbc_data_source($this->connection, SQL_FETCH_FIRST);
|
||||||
if (is_array($res)) {
|
if (is_array($res)) {
|
||||||
$out = array($res['server']);
|
$out = array($res['server']);
|
||||||
while($res = @odbc_data_source($this->connection,
|
while ($res = @odbc_data_source(
|
||||||
SQL_FETCH_NEXT))
|
$this->connection,
|
||||||
{
|
SQL_FETCH_NEXT
|
||||||
|
)) {
|
||||||
$out[] = $res['server'];
|
$out[] = $res['server'];
|
||||||
}
|
}
|
||||||
return $out;
|
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
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -54,13 +54,13 @@ class DB_pgsql extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'pgsql';
|
public $phptype = 'pgsql';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'pgsql';
|
public $dbsyntax = 'pgsql';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -75,7 +75,7 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => 'alter',
|
'limit' => 'alter',
|
||||||
'new_link' => '4.3.0',
|
'new_link' => '4.3.0',
|
||||||
'numrows' => true,
|
'numrows' => true,
|
||||||
@ -89,20 +89,20 @@ class DB_pgsql extends DB_common
|
|||||||
* A mapping of native error codes to DB error codes
|
* A mapping of native error codes to DB error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The raw database connection created by PHP
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,7 +110,7 @@ class DB_pgsql extends DB_common
|
|||||||
* @var bool
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $autocommit = true;
|
public $autocommit = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The quantity of transactions begun
|
* The quantity of transactions begun
|
||||||
@ -121,27 +121,27 @@ class DB_pgsql extends DB_common
|
|||||||
* @var integer
|
* @var integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $transaction_opcount = 0;
|
public $transaction_opcount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of rows affected by a data manipulation query
|
* The number of rows affected by a data manipulation query
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
var $affected = 0;
|
public $affected = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current row being looked at in fetchInto()
|
* The current row being looked at in fetchInto()
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $row = array();
|
public $row = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of rows in a given result set
|
* The number of rows in a given result set
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_num_rows = array();
|
public $_num_rows = array();
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -152,7 +152,7 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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
|
* @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')) {
|
if (!PEAR::loadExtension('pgsql')) {
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
||||||
@ -262,8 +262,7 @@ class DB_pgsql extends DB_common
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($dsn['new_link'])
|
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', '>=')) {
|
if (version_compare(phpversion(), '4.3.0', '>=')) {
|
||||||
$params[] = PGSQL_CONNECT_FORCE_NEW;
|
$params[] = PGSQL_CONNECT_FORCE_NEW;
|
||||||
}
|
}
|
||||||
@ -274,19 +273,27 @@ class DB_pgsql extends DB_common
|
|||||||
$ini = ini_get('track_errors');
|
$ini = ini_get('track_errors');
|
||||||
$php_errormsg = '';
|
$php_errormsg = '';
|
||||||
if ($ini) {
|
if ($ini) {
|
||||||
$this->connection = @call_user_func_array($connect_function,
|
$this->connection = @call_user_func_array(
|
||||||
$params);
|
$connect_function,
|
||||||
|
$params
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
@ini_set('track_errors', 1);
|
@ini_set('track_errors', 1);
|
||||||
$this->connection = @call_user_func_array($connect_function,
|
$this->connection = @call_user_func_array(
|
||||||
$params);
|
$connect_function,
|
||||||
|
$params
|
||||||
|
);
|
||||||
@ini_set('track_errors', $ini);
|
@ini_set('track_errors', $ini);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->connection) {
|
if (!$this->connection) {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
$php_errormsg);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$php_errormsg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return DB_OK;
|
return DB_OK;
|
||||||
}
|
}
|
||||||
@ -299,7 +306,7 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return bool TRUE on success, FALSE on failure
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$ret = @pg_close($this->connection);
|
$ret = @pg_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -318,7 +325,7 @@ class DB_pgsql extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$ismanip = $this->_checkManip($query);
|
$ismanip = $this->_checkManip($query);
|
||||||
$this->last_query = $query;
|
$this->last_query = $query;
|
||||||
@ -353,9 +360,10 @@ class DB_pgsql extends DB_common
|
|||||||
if ($ismanip) {
|
if ($ismanip) {
|
||||||
$this->affected = @pg_affected_rows($result);
|
$this->affected = @pg_affected_rows($result);
|
||||||
return DB_OK;
|
return DB_OK;
|
||||||
} elseif (preg_match('/^\s*\(*\s*(SELECT|EXPLAIN|FETCH|SHOW|WITH)\s/si',
|
} elseif (preg_match(
|
||||||
$query))
|
'/^\s*\(*\s*(SELECT|EXPLAIN|FETCH|SHOW|WITH)\s/si',
|
||||||
{
|
$query
|
||||||
|
)) {
|
||||||
$this->row[(int)$result] = 0; // reset the row counter.
|
$this->row[(int)$result] = 0; // reset the row counter.
|
||||||
$numrows = $this->numRows($result);
|
$numrows = $this->numRows($result);
|
||||||
if (is_object($numrows)) {
|
if (is_object($numrows)) {
|
||||||
@ -382,7 +390,7 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return true if a result is available otherwise return false
|
* @return true if a result is available otherwise return false
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -410,7 +418,7 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
$result_int = (int)$result;
|
$result_int = (int)$result;
|
||||||
$rownum = ($rownum !== null) ? $rownum : $this->row[$result_int];
|
$rownum = ($rownum !== null) ? $rownum : $this->row[$result_int];
|
||||||
@ -454,7 +462,7 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
if (is_resource($result)) {
|
if (is_resource($result)) {
|
||||||
unset($this->row[(int)$result]);
|
unset($this->row[(int)$result]);
|
||||||
@ -477,7 +485,8 @@ class DB_pgsql extends DB_common
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since release 1.7.8.
|
* @since Method available since release 1.7.8.
|
||||||
*/
|
*/
|
||||||
function quoteBoolean($boolean) {
|
public function quoteBoolean($boolean)
|
||||||
|
{
|
||||||
return $boolean ? 'TRUE' : 'FALSE';
|
return $boolean ? 'TRUE' : 'FALSE';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,7 +506,7 @@ class DB_pgsql extends DB_common
|
|||||||
* @see DB_common::quoteSmart()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function escapeSimple($str)
|
public function escapeSimple($str)
|
||||||
{
|
{
|
||||||
if (function_exists('pg_escape_string')) {
|
if (function_exists('pg_escape_string')) {
|
||||||
/* This fixes an undocumented BC break in PHP 5.2.0 which changed
|
/* 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()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
$cols = @pg_numfields($result);
|
$cols = @pg_numfields($result);
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
@ -557,7 +566,7 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numRows()
|
* @see DB_result::numRows()
|
||||||
*/
|
*/
|
||||||
function numRows($result)
|
public function numRows($result)
|
||||||
{
|
{
|
||||||
$rows = @pg_numrows($result);
|
$rows = @pg_numrows($result);
|
||||||
if ($rows === null) {
|
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
|
* @return int DB_OK on success. A DB_Error object if the driver
|
||||||
* doesn't support auto-committing transactions.
|
* doesn't support auto-committing transactions.
|
||||||
*/
|
*/
|
||||||
function autoCommit($onoff = false)
|
public function autoCommit($onoff = false)
|
||||||
{
|
{
|
||||||
// XXX if $this->transaction_opcount > 0, we should probably
|
// XXX if $this->transaction_opcount > 0, we should probably
|
||||||
// issue a warning here.
|
// 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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
// (disabled) hack to shut up error messages from libpq.a
|
// (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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
$result = @pg_exec($this->connection, 'abort;');
|
$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.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
return $this->affected;
|
return $this->affected;
|
||||||
}
|
}
|
||||||
@ -658,7 +667,7 @@ class DB_pgsql extends DB_common
|
|||||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||||
* DB_pgsql::createSequence(), DB_pgsql::dropSequence()
|
* DB_pgsql::createSequence(), DB_pgsql::dropSequence()
|
||||||
*/
|
*/
|
||||||
function nextId($seq_name, $ondemand = true)
|
public function nextId($seq_name, $ondemand = true)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
$repeat = false;
|
$repeat = false;
|
||||||
@ -700,7 +709,7 @@ class DB_pgsql extends DB_common
|
|||||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_pgsql::nextID(), DB_pgsql::dropSequence()
|
* DB_pgsql::nextID(), DB_pgsql::dropSequence()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
$result = $this->query("CREATE SEQUENCE ${seqname}");
|
$result = $this->query("CREATE SEQUENCE ${seqname}");
|
||||||
@ -720,7 +729,7 @@ class DB_pgsql extends DB_common
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_pgsql::nextID(), DB_pgsql::createSequence()
|
* DB_pgsql::nextID(), DB_pgsql::createSequence()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('DROP SEQUENCE '
|
return $this->query('DROP SEQUENCE '
|
||||||
. $this->getSequenceName($seq_name));
|
. $this->getSequenceName($seq_name));
|
||||||
@ -745,7 +754,7 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||||
{
|
{
|
||||||
return "$query LIMIT $count OFFSET $from";
|
return "$query LIMIT $count OFFSET $from";
|
||||||
}
|
}
|
||||||
@ -765,7 +774,7 @@ class DB_pgsql extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_pgsql::errorNative(), DB_pgsql::errorCode()
|
* DB_pgsql::errorNative(), DB_pgsql::errorCode()
|
||||||
*/
|
*/
|
||||||
function pgsqlRaiseError($errno = null)
|
public function pgsqlRaiseError($errno = null)
|
||||||
{
|
{
|
||||||
$native = $this->errorNative();
|
$native = $this->errorNative();
|
||||||
if (!$native) {
|
if (!$native) {
|
||||||
@ -789,7 +798,7 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @return string the DBMS' error message
|
* @return string the DBMS' error message
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
return @pg_errormessage($this->connection);
|
return @pg_errormessage($this->connection);
|
||||||
}
|
}
|
||||||
@ -803,7 +812,7 @@ class DB_pgsql extends DB_common
|
|||||||
* @param string $errormsg error message returned from the database
|
* @param string $errormsg error message returned from the database
|
||||||
* @return integer an error number from a DB error constant
|
* @return integer an error number from a DB error constant
|
||||||
*/
|
*/
|
||||||
function errorCode($errormsg)
|
public function errorCode($errormsg)
|
||||||
{
|
{
|
||||||
static $error_regexps;
|
static $error_regexps;
|
||||||
if (!isset($error_regexps)) {
|
if (!isset($error_regexps)) {
|
||||||
@ -880,7 +889,7 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_common::tableInfo()
|
* @see DB_common::tableInfo()
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if (is_string($result)) {
|
if (is_string($result)) {
|
||||||
/*
|
/*
|
||||||
@ -965,7 +974,7 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _pgFieldFlags($resource, $num_field, $table_name)
|
public function _pgFieldFlags($resource, $num_field, $table_name)
|
||||||
{
|
{
|
||||||
$field_name = @pg_fieldname($resource, $num_field);
|
$field_name = @pg_fieldname($resource, $num_field);
|
||||||
|
|
||||||
@ -1019,10 +1028,11 @@ class DB_pgsql extends DB_common
|
|||||||
if (in_array($num_field + 1, $keys)) {
|
if (in_array($num_field + 1, $keys)) {
|
||||||
$flags .= ($row[0] == 't' && $row[1] == 'f') ? 'unique_key ' : '';
|
$flags .= ($row[0] == 't' && $row[1] == 'f') ? 'unique_key ' : '';
|
||||||
$flags .= ($row[1] == 't') ? 'primary_key ' : '';
|
$flags .= ($row[1] == 't') ? 'primary_key ' : '';
|
||||||
if (count($keys) > 1)
|
if (count($keys) > 1) {
|
||||||
$flags .= 'multiple_key ';
|
$flags .= 'multiple_key ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return trim($flags);
|
return trim($flags);
|
||||||
}
|
}
|
||||||
@ -1041,7 +1051,7 @@ class DB_pgsql extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'tables':
|
case 'tables':
|
||||||
@ -1105,12 +1115,11 @@ class DB_pgsql extends DB_common
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function _checkManip($query)
|
public function _checkManip($query)
|
||||||
{
|
{
|
||||||
return (preg_match('/^\s*(SAVEPOINT|RELEASE)\s+/i', $query)
|
return (preg_match('/^\s*(SAVEPOINT|RELEASE)\s+/i', $query)
|
||||||
|| parent::_checkManip($query));
|
|| parent::_checkManip($query));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1119,5 +1128,3 @@ class DB_pgsql extends DB_common
|
|||||||
* c-basic-offset: 4
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -58,13 +58,13 @@ class DB_sqlite extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'sqlite';
|
public $phptype = 'sqlite';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'sqlite';
|
public $dbsyntax = 'sqlite';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -79,7 +79,7 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => 'alter',
|
'limit' => 'alter',
|
||||||
'new_link' => false,
|
'new_link' => false,
|
||||||
'numrows' => true,
|
'numrows' => true,
|
||||||
@ -98,20 +98,20 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The raw database connection created by PHP
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,7 +121,7 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $keywords = array (
|
public $keywords = array(
|
||||||
'BLOB' => '',
|
'BLOB' => '',
|
||||||
'BOOLEAN' => '',
|
'BOOLEAN' => '',
|
||||||
'CHARACTER' => '',
|
'CHARACTER' => '',
|
||||||
@ -145,7 +145,7 @@ class DB_sqlite extends DB_common
|
|||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_lasterror = '';
|
public $_lasterror = '';
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -156,7 +156,7 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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')) {
|
if (!PEAR::loadExtension('sqlite')) {
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
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);
|
return $this->sqliteRaiseError(DB_ERROR_NOT_FOUND);
|
||||||
}
|
}
|
||||||
if (!isset($dsn['mode']) ||
|
if (!isset($dsn['mode']) ||
|
||||||
!is_numeric($dsn['mode']))
|
!is_numeric($dsn['mode'])) {
|
||||||
{
|
|
||||||
$mode = 0644;
|
$mode = 0644;
|
||||||
} else {
|
} else {
|
||||||
$mode = octdec($dsn['mode']);
|
$mode = octdec($dsn['mode']);
|
||||||
@ -242,9 +241,13 @@ class DB_sqlite extends DB_common
|
|||||||
$php_errormsg = '';
|
$php_errormsg = '';
|
||||||
|
|
||||||
if (!$this->connection = @$connect_function($dsn['database'])) {
|
if (!$this->connection = @$connect_function($dsn['database'])) {
|
||||||
return $this->raiseError(DB_ERROR_NODBSELECTED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_NODBSELECTED,
|
||||||
$php_errormsg);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$php_errormsg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return DB_OK;
|
return DB_OK;
|
||||||
}
|
}
|
||||||
@ -257,7 +260,7 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @return bool TRUE on success, FALSE on failure
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$ret = @sqlite_close($this->connection);
|
$ret = @sqlite_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -280,7 +283,7 @@ class DB_sqlite extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$ismanip = $this->_checkManip($query);
|
$ismanip = $this->_checkManip($query);
|
||||||
$this->last_query = $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
|
* @return bool true if a result is available otherwise return false
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -347,7 +350,7 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
if ($rownum !== null) {
|
if ($rownum !== null) {
|
||||||
if (!@sqlite_seek($this->result, $rownum)) {
|
if (!@sqlite_seek($this->result, $rownum)) {
|
||||||
@ -405,7 +408,7 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult(&$result)
|
public function freeResult(&$result)
|
||||||
{
|
{
|
||||||
// XXX No native free?
|
// XXX No native free?
|
||||||
if (!is_resource($result)) {
|
if (!is_resource($result)) {
|
||||||
@ -431,7 +434,7 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
$cols = @sqlite_num_fields($result);
|
$cols = @sqlite_num_fields($result);
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
@ -456,7 +459,7 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numRows()
|
* @see DB_result::numRows()
|
||||||
*/
|
*/
|
||||||
function numRows($result)
|
public function numRows($result)
|
||||||
{
|
{
|
||||||
$rows = @sqlite_num_rows($result);
|
$rows = @sqlite_num_rows($result);
|
||||||
if ($rows === null) {
|
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.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
return @sqlite_changes($this->connection);
|
return @sqlite_changes($this->connection);
|
||||||
}
|
}
|
||||||
@ -493,7 +496,7 @@ class DB_sqlite extends DB_common
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_sqlite::nextID(), DB_sqlite::createSequence()
|
* DB_sqlite::nextID(), DB_sqlite::createSequence()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('DROP TABLE ' . $this->getSequenceName($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(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_sqlite::nextID(), DB_sqlite::dropSequence()
|
* DB_sqlite::nextID(), DB_sqlite::dropSequence()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
$query = 'CREATE TABLE ' . $seqname .
|
$query = 'CREATE TABLE ' . $seqname .
|
||||||
@ -543,7 +546,7 @@ class DB_sqlite extends DB_common
|
|||||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||||
* DB_sqlite::createSequence(), DB_sqlite::dropSequence()
|
* DB_sqlite::createSequence(), DB_sqlite::dropSequence()
|
||||||
*/
|
*/
|
||||||
function nextId($seq_name, $ondemand = true)
|
public function nextId($seq_name, $ondemand = true)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
|
|
||||||
@ -558,8 +561,7 @@ class DB_sqlite extends DB_common
|
|||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
} elseif ($ondemand && DB::isError($result) &&
|
} elseif ($ondemand && DB::isError($result) &&
|
||||||
$result->getCode() == DB_ERROR_NOSUCHTABLE)
|
$result->getCode() == DB_ERROR_NOSUCHTABLE) {
|
||||||
{
|
|
||||||
$result = $this->createSequence($seq_name);
|
$result = $this->createSequence($seq_name);
|
||||||
if (DB::isError($result)) {
|
if (DB::isError($result)) {
|
||||||
return $this->raiseError($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
|
* @return mixed an array on an unspecified key, integer on a passed
|
||||||
* arg and false at a stats error
|
* arg and false at a stats error
|
||||||
*/
|
*/
|
||||||
function getDbFileStats($arg = '')
|
public function getDbFileStats($arg = '')
|
||||||
{
|
{
|
||||||
$stats = stat($this->dsn['database']);
|
$stats = stat($this->dsn['database']);
|
||||||
if ($stats == false) {
|
if ($stats == false) {
|
||||||
@ -625,7 +627,7 @@ class DB_sqlite extends DB_common
|
|||||||
* @since Method available since Release 1.6.1
|
* @since Method available since Release 1.6.1
|
||||||
* @see DB_common::escapeSimple()
|
* @see DB_common::escapeSimple()
|
||||||
*/
|
*/
|
||||||
function escapeSimple($str)
|
public function escapeSimple($str)
|
||||||
{
|
{
|
||||||
return @sqlite_escape_string($str);
|
return @sqlite_escape_string($str);
|
||||||
}
|
}
|
||||||
@ -649,7 +651,7 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function modifyLimitQuery($query, $from, $count, $params = array())
|
public function modifyLimitQuery($query, $from, $count, $params = array())
|
||||||
{
|
{
|
||||||
return "$query LIMIT $count OFFSET $from";
|
return "$query LIMIT $count OFFSET $from";
|
||||||
}
|
}
|
||||||
@ -671,12 +673,15 @@ class DB_sqlite extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::setOption()
|
* @see DB_common::setOption()
|
||||||
*/
|
*/
|
||||||
function modifyQuery($query)
|
public function modifyQuery($query)
|
||||||
{
|
{
|
||||||
if ($this->options['portability'] & DB_PORTABILITY_DELETE_COUNT) {
|
if ($this->options['portability'] & DB_PORTABILITY_DELETE_COUNT) {
|
||||||
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) {
|
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) {
|
||||||
$query = preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/',
|
$query = preg_replace(
|
||||||
'DELETE FROM \1 WHERE 1=1', $query);
|
'/^\s*DELETE\s+FROM\s+(\S+)\s*$/',
|
||||||
|
'DELETE FROM \1 WHERE 1=1',
|
||||||
|
$query
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $query;
|
return $query;
|
||||||
@ -697,7 +702,7 @@ class DB_sqlite extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_sqlite::errorNative(), DB_sqlite::errorCode()
|
* DB_sqlite::errorNative(), DB_sqlite::errorCode()
|
||||||
*/
|
*/
|
||||||
function sqliteRaiseError($errno = null)
|
public function sqliteRaiseError($errno = null)
|
||||||
{
|
{
|
||||||
$native = $this->errorNative();
|
$native = $this->errorNative();
|
||||||
if ($errno === null) {
|
if ($errno === null) {
|
||||||
@ -721,7 +726,7 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @return string the DBMS' error message
|
* @return string the DBMS' error message
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
return $this->_lasterror;
|
return $this->_lasterror;
|
||||||
}
|
}
|
||||||
@ -736,7 +741,7 @@ class DB_sqlite extends DB_common
|
|||||||
*
|
*
|
||||||
* @return integer the DB error number
|
* @return integer the DB error number
|
||||||
*/
|
*/
|
||||||
function errorCode($errormsg)
|
public function errorCode($errormsg)
|
||||||
{
|
{
|
||||||
static $error_regexps;
|
static $error_regexps;
|
||||||
|
|
||||||
@ -785,22 +790,29 @@ class DB_sqlite extends DB_common
|
|||||||
* @see DB_common::tableInfo()
|
* @see DB_common::tableInfo()
|
||||||
* @since Method available since Release 1.7.0
|
* @since Method available since Release 1.7.0
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if (is_string($result)) {
|
if (is_string($result)) {
|
||||||
/*
|
/*
|
||||||
* Probably received a table name.
|
* Probably received a table name.
|
||||||
* Create a result resource identifier.
|
* Create a result resource identifier.
|
||||||
*/
|
*/
|
||||||
$id = @sqlite_array_query($this->connection,
|
$id = @sqlite_array_query(
|
||||||
|
$this->connection,
|
||||||
"PRAGMA table_info('$result');",
|
"PRAGMA table_info('$result');",
|
||||||
SQLITE_ASSOC);
|
SQLITE_ASSOC
|
||||||
|
);
|
||||||
$got_string = true;
|
$got_string = true;
|
||||||
} else {
|
} else {
|
||||||
$this->last_query = '';
|
$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' .
|
'This DBMS can not obtain tableInfo' .
|
||||||
' from result sets');
|
' from result sets'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
|
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
|
||||||
@ -877,11 +889,16 @@ class DB_sqlite extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type, $args = array())
|
public function getSpecialQuery($type, $args = array())
|
||||||
{
|
{
|
||||||
if (!is_array($args)) {
|
if (!is_array($args)) {
|
||||||
return $this->raiseError('no key specified', null, null, null,
|
return $this->raiseError(
|
||||||
'Argument has to be an array.');
|
'no key specified',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
'Argument has to be an array.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
@ -959,5 +976,3 @@ class DB_sqlite extends DB_common
|
|||||||
* c-basic-offset: 4
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -47,33 +47,33 @@ class DB_storage extends PEAR
|
|||||||
|
|
||||||
/** the name of the table (or view, if the backend database supports
|
/** the name of the table (or view, if the backend database supports
|
||||||
updates in views) we hold data from */
|
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
|
/** which column(s) in the table contains primary keys, can be a
|
||||||
string for single-column primary keys, or an array of strings
|
string for single-column primary keys, or an array of strings
|
||||||
for multiple-column primary keys */
|
for multiple-column primary keys */
|
||||||
var $_keycolumn = null;
|
public $_keycolumn = null;
|
||||||
|
|
||||||
/** DB connection handle used for all transactions */
|
/** DB connection handle used for all transactions */
|
||||||
var $_dbh = null;
|
public $_dbh = null;
|
||||||
|
|
||||||
/** an assoc with the names of database fields stored as properties
|
/** an assoc with the names of database fields stored as properties
|
||||||
in this object */
|
in this object */
|
||||||
var $_properties = array();
|
public $_properties = array();
|
||||||
|
|
||||||
/** an assoc with the names of the properties in this object that
|
/** an assoc with the names of the properties in this object that
|
||||||
have been changed since they were fetched from the database */
|
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.
|
/** flag that decides if data in this object can be changed.
|
||||||
objects that don't have their table's key column in their
|
objects that don't have their table's key column in their
|
||||||
property lists will be flagged as read-only. */
|
property lists will be flagged as read-only. */
|
||||||
var $_readonly = false;
|
public $_readonly = false;
|
||||||
|
|
||||||
/** function or method that implements a validator for fields that
|
/** function or method that implements a validator for fields that
|
||||||
are set, this validator function returns true if the field is
|
are set, this validator function returns true if the field is
|
||||||
valid, false if not */
|
valid, false if not */
|
||||||
var $_validator = null;
|
public $_validator = null;
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
// {{{ constructor
|
// {{{ constructor
|
||||||
@ -94,7 +94,7 @@ class DB_storage extends PEAR
|
|||||||
* a reference to this object
|
* 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->PEAR('DB_Error');
|
||||||
$this->_table = $table;
|
$this->_table = $table;
|
||||||
@ -115,7 +115,7 @@ class DB_storage extends PEAR
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _makeWhere($keyval = null)
|
public function _makeWhere($keyval = null)
|
||||||
{
|
{
|
||||||
if (is_array($this->_keycolumn)) {
|
if (is_array($this->_keycolumn)) {
|
||||||
if ($keyval === null) {
|
if ($keyval === null) {
|
||||||
@ -164,7 +164,7 @@ class DB_storage extends PEAR
|
|||||||
*
|
*
|
||||||
* @return int DB_OK on success, a DB error if not
|
* @return int DB_OK on success, a DB error if not
|
||||||
*/
|
*/
|
||||||
function setup($keyval)
|
public function setup($keyval)
|
||||||
{
|
{
|
||||||
$whereclause = $this->_makeWhere($keyval);
|
$whereclause = $this->_makeWhere($keyval);
|
||||||
$query = 'SELECT * FROM ' . $this->_table . ' WHERE ' . $whereclause;
|
$query = 'SELECT * FROM ' . $this->_table . ' WHERE ' . $whereclause;
|
||||||
@ -177,8 +177,15 @@ class DB_storage extends PEAR
|
|||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
return $this->raiseError(null, DB_ERROR_NOT_FOUND, null, null,
|
return $this->raiseError(
|
||||||
$query, null, true);
|
null,
|
||||||
|
DB_ERROR_NOT_FOUND,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
$query,
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
foreach ($row as $key => $value) {
|
foreach ($row as $key => $value) {
|
||||||
$this->_properties[$key] = true;
|
$this->_properties[$key] = true;
|
||||||
@ -194,7 +201,7 @@ class DB_storage extends PEAR
|
|||||||
* Create a new (empty) row in the configured table for this
|
* Create a new (empty) row in the configured table for this
|
||||||
* object.
|
* object.
|
||||||
*/
|
*/
|
||||||
function insert($newpk)
|
public function insert($newpk)
|
||||||
{
|
{
|
||||||
if (is_array($this->_keycolumn)) {
|
if (is_array($this->_keycolumn)) {
|
||||||
$primarykey = $this->_keycolumn;
|
$primarykey = $this->_keycolumn;
|
||||||
@ -225,7 +232,7 @@ class DB_storage extends PEAR
|
|||||||
* Output a simple description of this DB_storage object.
|
* Output a simple description of this DB_storage object.
|
||||||
* @return string object description
|
* @return string object description
|
||||||
*/
|
*/
|
||||||
function toString()
|
public function toString()
|
||||||
{
|
{
|
||||||
$info = strtolower(get_class($this));
|
$info = strtolower(get_class($this));
|
||||||
$info .= " (table=";
|
$info .= " (table=";
|
||||||
@ -272,7 +279,7 @@ class DB_storage extends PEAR
|
|||||||
/**
|
/**
|
||||||
* Dump the contents of this object to "standard output".
|
* Dump the contents of this object to "standard output".
|
||||||
*/
|
*/
|
||||||
function dump()
|
public function dump()
|
||||||
{
|
{
|
||||||
foreach ($this->_properties as $prop => $foo) {
|
foreach ($this->_properties as $prop => $foo) {
|
||||||
print "$prop = ";
|
print "$prop = ";
|
||||||
@ -290,7 +297,7 @@ class DB_storage extends PEAR
|
|||||||
* of properties/columns
|
* of properties/columns
|
||||||
* @return object a new instance of DB_storage or a subclass of it
|
* @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));
|
$classname = strtolower(get_class($this));
|
||||||
$obj = new $classname($table);
|
$obj = new $classname($table);
|
||||||
@ -359,24 +366,33 @@ class DB_storage extends PEAR
|
|||||||
/**
|
/**
|
||||||
* Modify an attriute value.
|
* Modify an attriute value.
|
||||||
*/
|
*/
|
||||||
function set($property, $newvalue)
|
public function set($property, $newvalue)
|
||||||
{
|
{
|
||||||
// only change if $property is known and object is not
|
// only change if $property is known and object is not
|
||||||
// read-only
|
// read-only
|
||||||
if ($this->_readonly) {
|
if ($this->_readonly) {
|
||||||
return $this->raiseError(null, DB_WARNING_READ_ONLY, null,
|
return $this->raiseError(
|
||||||
null, null, null, true);
|
null,
|
||||||
|
DB_WARNING_READ_ONLY,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (@isset($this->_properties[$property])) {
|
if (@isset($this->_properties[$property])) {
|
||||||
if (empty($this->_validator)) {
|
if (empty($this->_validator)) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
} else {
|
} else {
|
||||||
$valid = @call_user_func($this->_validator,
|
$valid = @call_user_func(
|
||||||
|
$this->_validator,
|
||||||
$this->_table,
|
$this->_table,
|
||||||
$property,
|
$property,
|
||||||
$newvalue,
|
$newvalue,
|
||||||
$this->$property,
|
$this->$property,
|
||||||
$this);
|
$this
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$this->$property = $newvalue;
|
$this->$property = $newvalue;
|
||||||
@ -386,15 +402,27 @@ class DB_storage extends PEAR
|
|||||||
$this->_changes[$property]++;
|
$this->_changes[$property]++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return $this->raiseError(null, DB_ERROR_INVALID, null,
|
return $this->raiseError(
|
||||||
null, "invalid field: $property",
|
null,
|
||||||
null, true);
|
DB_ERROR_INVALID,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
"invalid field: $property",
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return $this->raiseError(null, DB_ERROR_NOSUCHFIELD, null,
|
return $this->raiseError(
|
||||||
null, "unknown field: $property",
|
null,
|
||||||
null, true);
|
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
|
* @return attribute contents, or null if the attribute name is
|
||||||
* unknown
|
* unknown
|
||||||
*/
|
*/
|
||||||
function &get($property)
|
public function &get($property)
|
||||||
{
|
{
|
||||||
// only return if $property is known
|
// only return if $property is known
|
||||||
if (isset($this->_properties[$property])) {
|
if (isset($this->_properties[$property])) {
|
||||||
@ -425,7 +453,7 @@ class DB_storage extends PEAR
|
|||||||
* Destructor, calls DB_storage::store() if there are changes
|
* Destructor, calls DB_storage::store() if there are changes
|
||||||
* that are to be kept.
|
* that are to be kept.
|
||||||
*/
|
*/
|
||||||
function _DB_storage()
|
public function _DB_storage()
|
||||||
{
|
{
|
||||||
if (sizeof($this->_changes)) {
|
if (sizeof($this->_changes)) {
|
||||||
$this->store();
|
$this->store();
|
||||||
@ -443,7 +471,7 @@ class DB_storage extends PEAR
|
|||||||
*
|
*
|
||||||
* @return DB_OK or a DB error
|
* @return DB_OK or a DB error
|
||||||
*/
|
*/
|
||||||
function store()
|
public function store()
|
||||||
{
|
{
|
||||||
$params = array();
|
$params = array();
|
||||||
$vars = array();
|
$vars = array();
|
||||||
@ -473,11 +501,18 @@ class DB_storage extends PEAR
|
|||||||
*
|
*
|
||||||
* @return mixed DB_OK or a DB error
|
* @return mixed DB_OK or a DB error
|
||||||
*/
|
*/
|
||||||
function remove()
|
public function remove()
|
||||||
{
|
{
|
||||||
if ($this->_readonly) {
|
if ($this->_readonly) {
|
||||||
return $this->raiseError(null, DB_WARNING_READ_ONLY, null,
|
return $this->raiseError(
|
||||||
null, null, null, true);
|
null,
|
||||||
|
DB_WARNING_READ_ONLY,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$query = 'DELETE FROM ' . $this->_table .' WHERE '.
|
$query = 'DELETE FROM ' . $this->_table .' WHERE '.
|
||||||
$this->_makeWhere();
|
$this->_makeWhere();
|
||||||
@ -502,5 +537,3 @@ class DB_storage extends PEAR
|
|||||||
* c-basic-offset: 4
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -57,13 +57,13 @@ class DB_sybase extends DB_common
|
|||||||
* The DB driver type (mysql, oci8, odbc, etc.)
|
* The DB driver type (mysql, oci8, odbc, etc.)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $phptype = 'sybase';
|
public $phptype = 'sybase';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database syntax variant to be used (db2, access, etc.), if any
|
* The database syntax variant to be used (db2, access, etc.), if any
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $dbsyntax = 'sybase';
|
public $dbsyntax = 'sybase';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The capabilities of this DB implementation
|
* The capabilities of this DB implementation
|
||||||
@ -78,7 +78,7 @@ class DB_sybase extends DB_common
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $features = array(
|
public $features = array(
|
||||||
'limit' => 'emulate',
|
'limit' => 'emulate',
|
||||||
'new_link' => false,
|
'new_link' => false,
|
||||||
'numrows' => true,
|
'numrows' => true,
|
||||||
@ -92,20 +92,20 @@ class DB_sybase extends DB_common
|
|||||||
* A mapping of native error codes to DB error codes
|
* A mapping of native error codes to DB error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $errorcode_map = array(
|
public $errorcode_map = array(
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The raw database connection created by PHP
|
* The raw database connection created by PHP
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DSN information for connecting to a database
|
* The DSN information for connecting to a database
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $dsn = array();
|
public $dsn = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +113,7 @@ class DB_sybase extends DB_common
|
|||||||
* @var bool
|
* @var bool
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $autocommit = true;
|
public $autocommit = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The quantity of transactions begun
|
* The quantity of transactions begun
|
||||||
@ -124,7 +124,7 @@ class DB_sybase extends DB_common
|
|||||||
* @var integer
|
* @var integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $transaction_opcount = 0;
|
public $transaction_opcount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The database specified in the DSN
|
* The database specified in the DSN
|
||||||
@ -134,7 +134,7 @@ class DB_sybase extends DB_common
|
|||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_db = '';
|
public $_db = '';
|
||||||
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@ -145,7 +145,7 @@ class DB_sybase extends DB_common
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__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.
|
* @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') &&
|
if (!PEAR::loadExtension('sybase') &&
|
||||||
!PEAR::loadExtension('sybase_ct'))
|
!PEAR::loadExtension('sybase_ct')) {
|
||||||
{
|
|
||||||
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
|
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';
|
$connect_function = $persistent ? 'sybase_pconnect' : 'sybase_connect';
|
||||||
|
|
||||||
if ($dsn['username']) {
|
if ($dsn['username']) {
|
||||||
$this->connection = @$connect_function($dsn['hostspec'],
|
$this->connection = @$connect_function(
|
||||||
|
$dsn['hostspec'],
|
||||||
$dsn['username'],
|
$dsn['username'],
|
||||||
$dsn['password'],
|
$dsn['password'],
|
||||||
$dsn['charset'],
|
$dsn['charset'],
|
||||||
$dsn['appname']);
|
$dsn['appname']
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
'The DSN did not contain a username.');
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
'The DSN did not contain a username.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->connection) {
|
if (!$this->connection) {
|
||||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_CONNECT_FAILED,
|
||||||
@sybase_get_last_message());
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
@sybase_get_last_message()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($dsn['database']) {
|
if ($dsn['database']) {
|
||||||
if (!@sybase_select_db($dsn['database'], $this->connection)) {
|
if (!@sybase_select_db($dsn['database'], $this->connection)) {
|
||||||
return $this->raiseError(DB_ERROR_NODBSELECTED,
|
return $this->raiseError(
|
||||||
null, null, null,
|
DB_ERROR_NODBSELECTED,
|
||||||
@sybase_get_last_message());
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
@sybase_get_last_message()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->_db = $dsn['database'];
|
$this->_db = $dsn['database'];
|
||||||
}
|
}
|
||||||
@ -227,7 +240,7 @@ class DB_sybase extends DB_common
|
|||||||
*
|
*
|
||||||
* @return bool TRUE on success, FALSE on failure
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
$ret = @sybase_close($this->connection);
|
$ret = @sybase_close($this->connection);
|
||||||
$this->connection = null;
|
$this->connection = null;
|
||||||
@ -246,7 +259,7 @@ class DB_sybase extends DB_common
|
|||||||
* + the DB_OK constant for other successful queries
|
* + the DB_OK constant for other successful queries
|
||||||
* + a DB_Error object on failure
|
* + a DB_Error object on failure
|
||||||
*/
|
*/
|
||||||
function simpleQuery($query)
|
public function simpleQuery($query)
|
||||||
{
|
{
|
||||||
$ismanip = $this->_checkManip($query);
|
$ismanip = $this->_checkManip($query);
|
||||||
$this->last_query = $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
|
* @return true if a result is available otherwise return false
|
||||||
*/
|
*/
|
||||||
function nextResult($result)
|
public function nextResult($result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -315,7 +328,7 @@ class DB_sybase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::fetchInto()
|
* @see DB_result::fetchInto()
|
||||||
*/
|
*/
|
||||||
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
public function fetchInto($result, &$arr, $fetchmode, $rownum = null)
|
||||||
{
|
{
|
||||||
if ($rownum !== null) {
|
if ($rownum !== null) {
|
||||||
if (!@sybase_data_seek($result, $rownum)) {
|
if (!@sybase_data_seek($result, $rownum)) {
|
||||||
@ -368,7 +381,7 @@ class DB_sybase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::free()
|
* @see DB_result::free()
|
||||||
*/
|
*/
|
||||||
function freeResult($result)
|
public function freeResult($result)
|
||||||
{
|
{
|
||||||
return is_resource($result) ? sybase_free_result($result) : false;
|
return is_resource($result) ? sybase_free_result($result) : false;
|
||||||
}
|
}
|
||||||
@ -389,7 +402,7 @@ class DB_sybase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numCols()
|
* @see DB_result::numCols()
|
||||||
*/
|
*/
|
||||||
function numCols($result)
|
public function numCols($result)
|
||||||
{
|
{
|
||||||
$cols = @sybase_num_fields($result);
|
$cols = @sybase_num_fields($result);
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
@ -414,7 +427,7 @@ class DB_sybase extends DB_common
|
|||||||
*
|
*
|
||||||
* @see DB_result::numRows()
|
* @see DB_result::numRows()
|
||||||
*/
|
*/
|
||||||
function numRows($result)
|
public function numRows($result)
|
||||||
{
|
{
|
||||||
$rows = @sybase_num_rows($result);
|
$rows = @sybase_num_rows($result);
|
||||||
if ($rows === false) {
|
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.
|
* @return int the number of rows. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function affectedRows()
|
public function affectedRows()
|
||||||
{
|
{
|
||||||
if ($this->_last_query_manip) {
|
if ($this->_last_query_manip) {
|
||||||
$result = @sybase_affected_rows($this->connection);
|
$result = @sybase_affected_rows($this->connection);
|
||||||
@ -459,7 +472,7 @@ class DB_sybase extends DB_common
|
|||||||
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
* @see DB_common::nextID(), DB_common::getSequenceName(),
|
||||||
* DB_sybase::createSequence(), DB_sybase::dropSequence()
|
* DB_sybase::createSequence(), DB_sybase::dropSequence()
|
||||||
*/
|
*/
|
||||||
function nextId($seq_name, $ondemand = true)
|
public function nextId($seq_name, $ondemand = true)
|
||||||
{
|
{
|
||||||
$seqname = $this->getSequenceName($seq_name);
|
$seqname = $this->getSequenceName($seq_name);
|
||||||
if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) {
|
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)");
|
$result = $this->query("INSERT INTO $seqname (vapor) VALUES (0)");
|
||||||
$this->popErrorHandling();
|
$this->popErrorHandling();
|
||||||
if ($ondemand && DB::isError($result) &&
|
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;
|
$repeat = 1;
|
||||||
$result = $this->createSequence($seq_name);
|
$result = $this->createSequence($seq_name);
|
||||||
if (DB::isError($result)) {
|
if (DB::isError($result)) {
|
||||||
@ -502,7 +514,7 @@ class DB_sybase extends DB_common
|
|||||||
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
* @see DB_common::createSequence(), DB_common::getSequenceName(),
|
||||||
* DB_sybase::nextID(), DB_sybase::dropSequence()
|
* DB_sybase::nextID(), DB_sybase::dropSequence()
|
||||||
*/
|
*/
|
||||||
function createSequence($seq_name)
|
public function createSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('CREATE TABLE '
|
return $this->query('CREATE TABLE '
|
||||||
. $this->getSequenceName($seq_name)
|
. $this->getSequenceName($seq_name)
|
||||||
@ -523,7 +535,7 @@ class DB_sybase extends DB_common
|
|||||||
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
|
||||||
* DB_sybase::nextID(), DB_sybase::createSequence()
|
* DB_sybase::nextID(), DB_sybase::createSequence()
|
||||||
*/
|
*/
|
||||||
function dropSequence($seq_name)
|
public function dropSequence($seq_name)
|
||||||
{
|
{
|
||||||
return $this->query('DROP TABLE ' . $this->getSequenceName($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()
|
* @see DB_common::quoteSmart()
|
||||||
* @since Method available since release 1.7.8.
|
* @since Method available since release 1.7.8.
|
||||||
*/
|
*/
|
||||||
function quoteFloat($float) {
|
public function quoteFloat($float)
|
||||||
|
{
|
||||||
return $this->escapeSimple(str_replace(',', '.', strval(floatval($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
|
* @return int DB_OK on success. A DB_Error object if the driver
|
||||||
* doesn't support auto-committing transactions.
|
* doesn't support auto-committing transactions.
|
||||||
*/
|
*/
|
||||||
function autoCommit($onoff = false)
|
public function autoCommit($onoff = false)
|
||||||
{
|
{
|
||||||
// XXX if $this->transaction_opcount > 0, we should probably
|
// XXX if $this->transaction_opcount > 0, we should probably
|
||||||
// issue a warning here.
|
// 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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) {
|
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.
|
* @return int DB_OK on success. A DB_Error object on failure.
|
||||||
*/
|
*/
|
||||||
function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
if ($this->transaction_opcount > 0) {
|
if ($this->transaction_opcount > 0) {
|
||||||
if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) {
|
if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) {
|
||||||
@ -624,7 +637,7 @@ class DB_sybase extends DB_common
|
|||||||
* @see DB_common::raiseError(),
|
* @see DB_common::raiseError(),
|
||||||
* DB_sybase::errorNative(), DB_sybase::errorCode()
|
* DB_sybase::errorNative(), DB_sybase::errorCode()
|
||||||
*/
|
*/
|
||||||
function sybaseRaiseError($errno = null)
|
public function sybaseRaiseError($errno = null)
|
||||||
{
|
{
|
||||||
$native = $this->errorNative();
|
$native = $this->errorNative();
|
||||||
if ($errno === null) {
|
if ($errno === null) {
|
||||||
@ -641,7 +654,7 @@ class DB_sybase extends DB_common
|
|||||||
*
|
*
|
||||||
* @return string the DBMS' error message
|
* @return string the DBMS' error message
|
||||||
*/
|
*/
|
||||||
function errorNative()
|
public function errorNative()
|
||||||
{
|
{
|
||||||
return @sybase_get_last_message();
|
return @sybase_get_last_message();
|
||||||
}
|
}
|
||||||
@ -655,7 +668,7 @@ class DB_sybase extends DB_common
|
|||||||
* @param string $errormsg error message returned from the database
|
* @param string $errormsg error message returned from the database
|
||||||
* @return integer an error number from a DB error constant
|
* @return integer an error number from a DB error constant
|
||||||
*/
|
*/
|
||||||
function errorCode($errormsg)
|
public function errorCode($errormsg)
|
||||||
{
|
{
|
||||||
static $error_regexps;
|
static $error_regexps;
|
||||||
|
|
||||||
@ -730,7 +743,7 @@ class DB_sybase extends DB_common
|
|||||||
* @see DB_common::tableInfo()
|
* @see DB_common::tableInfo()
|
||||||
* @since Method available since Release 1.6.0
|
* @since Method available since Release 1.6.0
|
||||||
*/
|
*/
|
||||||
function tableInfo($result, $mode = null)
|
public function tableInfo($result, $mode = null)
|
||||||
{
|
{
|
||||||
if (is_string($result)) {
|
if (is_string($result)) {
|
||||||
/*
|
/*
|
||||||
@ -740,8 +753,10 @@ class DB_sybase extends DB_common
|
|||||||
if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) {
|
if ($this->_db && !@sybase_select_db($this->_db, $this->connection)) {
|
||||||
return $this->sybaseRaiseError(DB_ERROR_NODBSELECTED);
|
return $this->sybaseRaiseError(DB_ERROR_NODBSELECTED);
|
||||||
}
|
}
|
||||||
$id = @sybase_query("SELECT * FROM $result WHERE 1=0",
|
$id = @sybase_query(
|
||||||
$this->connection);
|
"SELECT * FROM $result WHERE 1=0",
|
||||||
|
$this->connection
|
||||||
|
);
|
||||||
$got_string = true;
|
$got_string = true;
|
||||||
} elseif (isset($result->result)) {
|
} elseif (isset($result->result)) {
|
||||||
/*
|
/*
|
||||||
@ -791,7 +806,9 @@ class DB_sybase extends DB_common
|
|||||||
);
|
);
|
||||||
if ($res[$i]['table']) {
|
if ($res[$i]['table']) {
|
||||||
$res[$i]['flags'] = $this->_sybase_field_flags(
|
$res[$i]['flags'] = $this->_sybase_field_flags(
|
||||||
$res[$i]['table'], $res[$i]['name']);
|
$res[$i]['table'],
|
||||||
|
$res[$i]['name']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if ($mode & DB_TABLEINFO_ORDER) {
|
if ($mode & DB_TABLEINFO_ORDER) {
|
||||||
$res['order'][$res[$i]['name']] = $i;
|
$res['order'][$res[$i]['name']] = $i;
|
||||||
@ -825,7 +842,7 @@ class DB_sybase extends DB_common
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _sybase_field_flags($table, $column)
|
public function _sybase_field_flags($table, $column)
|
||||||
{
|
{
|
||||||
static $tableName = null;
|
static $tableName = null;
|
||||||
static $flags = array();
|
static $flags = array();
|
||||||
@ -868,7 +885,6 @@ class DB_sybase extends DB_common
|
|||||||
}
|
}
|
||||||
|
|
||||||
sybase_free_result($res);
|
sybase_free_result($res);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists($column, $flags)) {
|
if (array_key_exists($column, $flags)) {
|
||||||
@ -892,7 +908,7 @@ class DB_sybase extends DB_common
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _add_flag(&$array, $value)
|
public function _add_flag(&$array, $value)
|
||||||
{
|
{
|
||||||
if (!is_array($array)) {
|
if (!is_array($array)) {
|
||||||
$array = array($value);
|
$array = array($value);
|
||||||
@ -915,7 +931,7 @@ class DB_sybase extends DB_common
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @see DB_common::getListOf()
|
* @see DB_common::getListOf()
|
||||||
*/
|
*/
|
||||||
function getSpecialQuery($type)
|
public function getSpecialQuery($type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'tables':
|
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
|
* c-basic-offset: 4
|
||||||
* End:
|
* End:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user