| version 1.2, 2005/11/07 20:37:25 |
version 1.3, 2011/06/17 13:56:39 |
|
|
| * @author Sterling Hughes <sterling@php.net> |
* @author Sterling Hughes <sterling@php.net> |
| * @author Antônio Carlos Venâncio Júnior <floripa@php.net> |
* @author Antônio Carlos Venâncio Júnior <floripa@php.net> |
| * @author Daniel Convissor <danielc@php.net> |
* @author Daniel Convissor <danielc@php.net> |
| * @copyright 1997-2005 The PHP Group |
* @copyright 1997-2007 The PHP Group |
| * @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
| * @version CVS: $Id$ |
* @version CVS: $Id$ |
| * @link http://pear.php.net/package/DB |
* @link http://pear.php.net/package/DB |
| Line 44 require_once 'DB/common.php'; |
|
| Line 44 require_once 'DB/common.php'; |
|
| * @author Sterling Hughes <sterling@php.net> |
* @author Sterling Hughes <sterling@php.net> |
| * @author Antônio Carlos Venâncio Júnior <floripa@php.net> |
* @author Antônio Carlos Venâncio Júnior <floripa@php.net> |
| * @author Daniel Convissor <danielc@php.net> |
* @author Daniel Convissor <danielc@php.net> |
| * @copyright 1997-2005 The PHP Group |
* @copyright 1997-2007 The PHP Group |
| * @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
| * @version Release: 1.7.6 |
* @version Release: 1.7.14RC2 |
| * @link http://pear.php.net/package/DB |
* @link http://pear.php.net/package/DB |
| */ |
*/ |
| class DB_sybase extends DB_common |
class DB_sybase extends DB_common |
| Line 248 class DB_sybase extends DB_common |
|
| Line 248 class DB_sybase extends DB_common |
|
| */ |
*/ |
| function simpleQuery($query) |
function simpleQuery($query) |
| { |
{ |
| $ismanip = DB::isManip($query); |
$ismanip = $this->_checkManip($query); |
| $this->last_query = $query; |
$this->last_query = $query; |
| if (!@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); |
| } |
} |
| $query = $this->modifyQuery($query); |
$query = $this->modifyQuery($query); |
| Line 370 class DB_sybase extends DB_common |
|
| Line 370 class DB_sybase extends DB_common |
|
| */ |
*/ |
| function freeResult($result) |
function freeResult($result) |
| { |
{ |
| return @sybase_free_result($result); |
return is_resource($result) ? sybase_free_result($result) : false; |
| } |
} |
| |
|
| // }}} |
// }}} |
| Line 435 class DB_sybase extends DB_common |
|
| Line 435 class DB_sybase extends DB_common |
|
| */ |
*/ |
| function affectedRows() |
function affectedRows() |
| { |
{ |
| if (DB::isManip($this->last_query)) { |
if ($this->_last_query_manip) { |
| $result = @sybase_affected_rows($this->connection); |
$result = @sybase_affected_rows($this->connection); |
| } else { |
} else { |
| $result = 0; |
$result = 0; |
| Line 462 class DB_sybase extends DB_common |
|
| Line 462 class DB_sybase extends DB_common |
|
| function nextId($seq_name, $ondemand = true) |
function nextId($seq_name, $ondemand = true) |
| { |
{ |
| $seqname = $this->getSequenceName($seq_name); |
$seqname = $this->getSequenceName($seq_name); |
| if (!@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); |
| } |
} |
| $repeat = 0; |
$repeat = 0; |
| Line 479 class DB_sybase extends DB_common |
|
| Line 479 class DB_sybase extends DB_common |
|
| return $this->raiseError($result); |
return $this->raiseError($result); |
| } |
} |
| } elseif (!DB::isError($result)) { |
} elseif (!DB::isError($result)) { |
| $result =& $this->query("SELECT @@IDENTITY FROM $seqname"); |
$result = $this->query("SELECT @@IDENTITY FROM $seqname"); |
| $repeat = 0; |
$repeat = 0; |
| } else { |
} else { |
| $repeat = false; |
$repeat = false; |
| Line 529 class DB_sybase extends DB_common |
|
| Line 529 class DB_sybase extends DB_common |
|
| } |
} |
| |
|
| // }}} |
// }}} |
| |
// {{{ quoteFloat() |
| |
|
| |
/** |
| |
* Formats a float value for use within a query in a locale-independent |
| |
* manner. |
| |
* |
| |
* @param float the float value to be quoted. |
| |
* @return string the quoted string. |
| |
* @see DB_common::quoteSmart() |
| |
* @since Method available since release 1.7.8. |
| |
*/ |
| |
function quoteFloat($float) { |
| |
return $this->escapeSimple(str_replace(',', '.', strval(floatval($float)))); |
| |
} |
| |
|
| |
// }}} |
| // {{{ autoCommit() |
// {{{ autoCommit() |
| |
|
| /** |
/** |
| Line 558 class DB_sybase extends DB_common |
|
| Line 574 class DB_sybase extends DB_common |
|
| function commit() |
function commit() |
| { |
{ |
| if ($this->transaction_opcount > 0) { |
if ($this->transaction_opcount > 0) { |
| if (!@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); |
| } |
} |
| $result = @sybase_query('COMMIT', $this->connection); |
$result = @sybase_query('COMMIT', $this->connection); |
| Line 581 class DB_sybase extends DB_common |
|
| Line 597 class DB_sybase extends DB_common |
|
| function rollback() |
function rollback() |
| { |
{ |
| if ($this->transaction_opcount > 0) { |
if ($this->transaction_opcount > 0) { |
| if (!@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); |
| } |
} |
| $result = @sybase_query('ROLLBACK', $this->connection); |
$result = @sybase_query('ROLLBACK', $this->connection); |
| Line 642 class DB_sybase extends DB_common |
|
| Line 658 class DB_sybase extends DB_common |
|
| function errorCode($errormsg) |
function errorCode($errormsg) |
| { |
{ |
| static $error_regexps; |
static $error_regexps; |
| |
|
| |
// PHP 5.2+ prepends the function name to $php_errormsg, so we need |
| |
// this hack to work around it, per bug #9599. |
| |
$errormsg = preg_replace('/^sybase[a-z_]+\(\): /', '', $errormsg); |
| |
|
| if (!isset($error_regexps)) { |
if (!isset($error_regexps)) { |
| $error_regexps = array( |
$error_regexps = array( |
| '/Incorrect syntax near/' |
'/Incorrect syntax near/' |
| Line 674 class DB_sybase extends DB_common |
|
| Line 695 class DB_sybase extends DB_common |
|
| => DB_ERROR_ALREADY_EXISTS, |
=> DB_ERROR_ALREADY_EXISTS, |
| '/^There are fewer columns in the INSERT statement than values specified/i' |
'/^There are fewer columns in the INSERT statement than values specified/i' |
| => DB_ERROR_VALUE_COUNT_ON_ROW, |
=> DB_ERROR_VALUE_COUNT_ON_ROW, |
| |
'/Divide by zero/i' |
| |
=> DB_ERROR_DIVZERO, |
| ); |
); |
| } |
} |
| |
|
| Line 714 class DB_sybase extends DB_common |
|
| Line 737 class DB_sybase extends DB_common |
|
| * Probably received a table name. |
* Probably received a table name. |
| * Create a result resource identifier. |
* Create a result resource identifier. |
| */ |
*/ |
| if (!@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("SELECT * FROM $result WHERE 1=0", |
| Line 811 class DB_sybase extends DB_common |
|
| Line 834 class DB_sybase extends DB_common |
|
| $flags = array(); |
$flags = array(); |
| $tableName = $table; |
$tableName = $table; |
| |
|
| // get unique/primary keys |
/* We're running sp_helpindex directly because it doesn't exist in |
| $res = $this->getAll("sp_helpindex $table", DB_FETCHMODE_ASSOC); |
* older versions of ASE -- unfortunately, we can't just use |
| |
* DB::isError() because the user may be using callback error |
| |
* handling. */ |
| |
$res = @sybase_query("sp_helpindex $table", $this->connection); |
| |
|
| if (!isset($res[0]['index_description'])) { |
if ($res === false || $res === true) { |
| |
// Fake a valid response for BC reasons. |
| return ''; |
return ''; |
| } |
} |
| |
|
| foreach ($res as $val) { |
while (($val = sybase_fetch_assoc($res)) !== false) { |
| |
if (!isset($val['index_keys'])) { |
| |
/* No useful information returned. Break and be done with |
| |
* it, which preserves the pre-1.7.9 behaviour. */ |
| |
break; |
| |
} |
| |
|
| $keys = explode(', ', trim($val['index_keys'])); |
$keys = explode(', ', trim($val['index_keys'])); |
| |
|
| if (sizeof($keys) > 1) { |
if (sizeof($keys) > 1) { |
| Line 834 class DB_sybase extends DB_common |
|
| Line 867 class DB_sybase extends DB_common |
|
| } |
} |
| } |
} |
| |
|
| |
sybase_free_result($res); |
| |
|
| } |
} |
| |
|
| if (array_key_exists($column, $flags)) { |
if (array_key_exists($column, $flags)) { |