mirror of
https://github.com/dg/dibi.git
synced 2025-08-11 00:24:19 +02:00
fixed some bugs
This commit is contained in:
@@ -266,7 +266,7 @@ class DibiMySqlDriver extends NObject implements DibiDriverInterface
|
||||
public function rowCount()
|
||||
{
|
||||
if (!$this->buffered) {
|
||||
throw new BadMethodCallException(__METHOD__ . ' is not allowed for unbuffered queries');
|
||||
throw new DibiDatabaseException('Row count is not available for unbuffered queries');
|
||||
}
|
||||
return mysql_num_rows($this->resultset);
|
||||
}
|
||||
@@ -296,8 +296,9 @@ class DibiMySqlDriver extends NObject implements DibiDriverInterface
|
||||
public function seek($row)
|
||||
{
|
||||
if (!$this->buffered) {
|
||||
throw new BadMethodCallException(__METHOD__ . ' is not allowed for unbuffered queries');
|
||||
throw new DibiDatabaseException('Cannot seek an unbuffered result set');
|
||||
}
|
||||
|
||||
if (!mysql_data_seek($this->resultset, $row)) {
|
||||
throw new DibiDatabaseException('Unable to seek to row ' . $row);
|
||||
}
|
||||
|
@@ -251,7 +251,7 @@ class DibiMySqliDriver extends NObject implements DibiDriverInterface
|
||||
public function rowCount()
|
||||
{
|
||||
if (!$this->buffered) {
|
||||
throw new BadMethodCallException(__METHOD__ . ' is not allowed for unbuffered queries');
|
||||
throw new DibiDatabaseException('Row count is not available for unbuffered queries');
|
||||
}
|
||||
return mysqli_num_rows($this->resultset);
|
||||
}
|
||||
@@ -281,7 +281,7 @@ class DibiMySqliDriver extends NObject implements DibiDriverInterface
|
||||
public function seek($row)
|
||||
{
|
||||
if (!$this->buffered) {
|
||||
throw new BadMethodCallException(__METHOD__ . ' is not allowed for unbuffered queries');
|
||||
throw new DibiDatabaseException('Cannot seek an unbuffered result set');
|
||||
}
|
||||
if (!mysqli_data_seek($this->resultset, $row)) {
|
||||
throw new DibiDatabaseException('Unable to seek to row ' . $row);
|
||||
|
@@ -85,7 +85,7 @@ class DibiOdbcDriver extends NObject implements DibiDriverInterface
|
||||
}
|
||||
|
||||
if (!is_resource($this->connection)) {
|
||||
throw new DibiDatabaseException(odbc_errormsg(), odbc_error());
|
||||
throw new DibiDatabaseException(odbc_errormsg() . ' ' . odbc_error());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,11 +112,10 @@ class DibiOdbcDriver extends NObject implements DibiDriverInterface
|
||||
*/
|
||||
public function query($sql)
|
||||
{
|
||||
$this->affectedRows = FALSE;
|
||||
$this->resultset = @odbc_exec($this->connection, $sql);
|
||||
|
||||
if ($this->resultset === FALSE) {
|
||||
throw new DibiDatabaseException(odbc_errormsg($this->connection), odbc_error($this->connection), $sql);
|
||||
throw new DibiDatabaseException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection), 0, $sql);
|
||||
}
|
||||
|
||||
return is_resource($this->resultset);
|
||||
@@ -155,7 +154,7 @@ class DibiOdbcDriver extends NObject implements DibiDriverInterface
|
||||
public function begin()
|
||||
{
|
||||
if (!odbc_autocommit($this->connection, FALSE)) {
|
||||
throw new DibiDatabaseException(odbc_errormsg($this->connection), odbc_error($this->connection));
|
||||
throw new DibiDatabaseException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +167,7 @@ class DibiOdbcDriver extends NObject implements DibiDriverInterface
|
||||
public function commit()
|
||||
{
|
||||
if (!odbc_commit($this->connection)) {
|
||||
throw new DibiDatabaseException(odbc_errormsg($this->connection), odbc_error($this->connection));
|
||||
throw new DibiDatabaseException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection));
|
||||
}
|
||||
odbc_autocommit($this->connection, TRUE);
|
||||
}
|
||||
@@ -182,7 +181,7 @@ class DibiOdbcDriver extends NObject implements DibiDriverInterface
|
||||
public function rollback()
|
||||
{
|
||||
if (!odbc_rollback($this->connection)) {
|
||||
throw new DibiDatabaseException(odbc_errormsg($this->connection), odbc_error($this->connection));
|
||||
throw new DibiDatabaseException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection));
|
||||
}
|
||||
odbc_autocommit($this->connection, TRUE);
|
||||
}
|
||||
@@ -285,11 +284,6 @@ class DibiOdbcDriver extends NObject implements DibiDriverInterface
|
||||
/** this is experimental */
|
||||
public function buildMeta()
|
||||
{
|
||||
// cache
|
||||
if ($meta !== NULL) {
|
||||
return $meta;
|
||||
}
|
||||
|
||||
static $types = array(
|
||||
'CHAR' => dibi::FIELD_TEXT,
|
||||
'COUNTER' => dibi::FIELD_COUNTER,
|
||||
|
@@ -244,7 +244,6 @@ class DibiOracleDriver extends NObject implements DibiDriverInterface
|
||||
*/
|
||||
public function fetch()
|
||||
{
|
||||
$this->fetched = TRUE;
|
||||
return oci_fetch_assoc($this->resultset);
|
||||
}
|
||||
|
||||
@@ -259,7 +258,6 @@ class DibiOracleDriver extends NObject implements DibiDriverInterface
|
||||
*/
|
||||
public function seek($row)
|
||||
{
|
||||
if ($row === 0 && !$this->fetched) return TRUE;
|
||||
throw new BadMethodCallException(__METHOD__ . ' is not implemented');
|
||||
}
|
||||
|
||||
|
@@ -231,6 +231,7 @@ class DibiPdoDriver extends NObject implements DibiDriverInterface
|
||||
*/
|
||||
public function seek($row)
|
||||
{
|
||||
$this->row = $row;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -224,7 +224,7 @@ class DibiSqliteDriver extends NObject implements DibiDriverInterface
|
||||
public function rowCount()
|
||||
{
|
||||
if (!$this->buffered) {
|
||||
throw new BadMethodCallException(__METHOD__ . ' is not allowed for unbuffered queries');
|
||||
throw new DibiDatabaseException('Row count is not available for unbuffered queries');
|
||||
}
|
||||
return sqlite_num_rows($this->resultset);
|
||||
}
|
||||
@@ -254,11 +254,11 @@ class DibiSqliteDriver extends NObject implements DibiDriverInterface
|
||||
public function seek($row)
|
||||
{
|
||||
if (!$this->buffered) {
|
||||
throw new BadMethodCallException(__METHOD__ . ' is not allowed for unbuffered queries');
|
||||
throw new DibiDatabaseException('Cannot seek an unbuffered result set');
|
||||
}
|
||||
if (!sqlite_seek($this->resultset, $row)) {
|
||||
throw new DibiDatabaseException('Unable to seek to row ' . $row);
|
||||
}
|
||||
DibiDatabaseException::catchError();
|
||||
sqlite_seek($this->resultset, $row);
|
||||
DibiDatabaseException::restore();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user