cvs: pear /MDB2/MDB2/Driver fbsql.php ibase.php mssql.php mysql.php pgsql.php querysim.php sqlite.php

From: Date: Fri, 21 May 2004 11:43:29 +0000
Subject: cvs: pear /MDB2/MDB2/Driver fbsql.php ibase.php mssql.php mysql.php pgsql.php querysim.php sqlite.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-19727@lists.php.net to get a copy of this message
lsmith Fri May 21 07:43:29 2004 EDT Modified files: /pear/MDB2/MDB2/Driver fbsql.php ibase.php mssql.php mysql.php pgsql.php querysim.php sqlite.php Log: - allow errorInfo() to be called when no connection has been established yet - cleaned up constructor handling

http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/fbsql.php?r1=1.18&r2=1.19&ty=u Index: pear/MDB2/MDB2/Driver/fbsql.php diff -u pear/MDB2/MDB2/Driver/fbsql.php:1.18 pear/MDB2/MDB2/Driver/fbsql.php:1.19 --- pear/MDB2/MDB2/Driver/fbsql.php:1.18 Wed May 12 09:00:09 2004 +++ pear/MDB2/MDB2/Driver/fbsql.php Fri May 21 07:43:28 2004 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: fbsql.php,v 1.18 2004/05/12 13:00:09 lsmith Exp $ +// $Id: fbsql.php,v 1.19 2004/05/21 11:43:28 lsmith Exp $ // /** @@ -67,9 +67,10 @@ /** * Constructor */ - function MDB2_fbsql() + function __construct() { - $this->MDB2_Driver_Common(); + parent::__construct(); + $this->phptype = 'fbsql'; $this->dbsyntax = 'fbsql'; @@ -86,6 +87,11 @@ $this->supported['auto_increment'] = true; } + function MDB2_Driver_fbsql() + { + $this->__construct(); + } + // }}} // {{{ errorInfo() @@ -98,8 +104,13 @@ */ function errorInfo($error = null) { - $native_code = @fbsql_errno($this->connection); - $native_msg = @fbsql_error($this->connection); + if($this->connection) { + $native_code = @fbsql_errno($this->connection); + $native_msg = @fbsql_error($this->connection); + } else { + $native_code = @fbsql_errno(); + $native_msg = @fbsql_error(); + } if (is_null($error)) { static $ecode_map; if (empty($ecode_map)) { @@ -261,7 +272,6 @@ $user = $dsninfo['username']; $pw = $dsninfo['password']; - @ini_set('track_errors', true); if ($dbhost && $user && $pw) { $connection = @$function($dbhost, $user, $pw); } elseif ($dbhost && $user) { @@ -271,10 +281,8 @@ } else { $connection = 0; } - @ini_restore('track_errors'); if ($connection <= 0) { - return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, - $php_errormsg); + return $this->raiseError(MDB2_ERROR_CONNECT_FAILED); } $this->connection = $connection; $this->connected_dsn = $this->dsn; @@ -528,17 +536,6 @@ class MDB2_Result_fbsql extends MDB2_Result_Common { // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_Result_fbsql(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_Common($mdb, $result, $offset, $limit); - } - - // }}} // {{{ fetch() /** @@ -725,17 +722,6 @@ class MDB2_BufferedResult_fbsql extends MDB2_Result_fbsql { // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_BufferedResult_mysql(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_mysql($mdb, $result, $offset, $limit); - } - - // }}} // {{{ seek() /** http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/ibase.php?r1=1.31&r2=1.32&ty=u Index: pear/MDB2/MDB2/Driver/ibase.php diff -u pear/MDB2/MDB2/Driver/ibase.php:1.31 pear/MDB2/MDB2/Driver/ibase.php:1.32 --- pear/MDB2/MDB2/Driver/ibase.php:1.31 Wed May 12 11:54:16 2004 +++ pear/MDB2/MDB2/Driver/ibase.php Fri May 21 07:43:28 2004 @@ -43,7 +43,7 @@ // | Author: Lorenzo Alberton <l.alberton@quipo.it> | // +----------------------------------------------------------------------+ // -// $Id: ibase.php,v 1.31 2004/05/12 15:54:16 quipo Exp $ +// $Id: ibase.php,v 1.32 2004/05/21 11:43:28 lsmith Exp $ /** * MDB2 FireBird/InterBase driver @@ -71,9 +71,10 @@ /** * Constructor */ - function MDB2_Driver_ibase() + function __construct() { - $this->MDB2_Driver_Common(); + parent::__construct(); + $this->phptype = 'ibase'; $this->dbsyntax = 'ibase'; @@ -96,6 +97,11 @@ $this->options['default_text_field_length'] = 4000; } + function MDB2_Driver_ibase() + { + $this->__construct(); + } + // }}} // {{{ errorInfo() @@ -332,12 +338,8 @@ @ibase_timefmt("%Y-%m-%d", IBASE_DATE); return $connection; } - if (isset($php_errormsg)) { - $error_msg = $php_errormsg; - } else { - $error_msg = 'Could not connect to FireBird/InterBase server'; - } - return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, $error_msg); + + return $this->raiseError(MDB2_ERROR_CONNECT_FAILED); } // }}} @@ -633,17 +635,6 @@ class MDB2_Result_ibase extends MDB2_Result_Common { // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_Result_ibase(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_Common($mdb, $result, $offset, $limit); - } - - // }}} // {{{ _skipLimitOffset() /** @@ -856,18 +847,6 @@ var $buffer; var $buffer_rownum = - 1; - // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_BufferedResult_ibase(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_ibase($mdb, $result, $offset, $limit); - } - - // }}} // {{{ _fillBuffer() /** http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/mssql.php?r1=1.19&r2=1.20&ty=u Index: pear/MDB2/MDB2/Driver/mssql.php diff -u pear/MDB2/MDB2/Driver/mssql.php:1.19 pear/MDB2/MDB2/Driver/mssql.php:1.20 --- pear/MDB2/MDB2/Driver/mssql.php:1.19 Wed May 12 09:00:09 2004 +++ pear/MDB2/MDB2/Driver/mssql.php Fri May 21 07:43:28 2004 @@ -43,7 +43,7 @@ // | Author: Frank M. Kromann <frank@kromann.info> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.19 2004/05/12 13:00:09 lsmith Exp $ +// $Id: mssql.php,v 1.20 2004/05/21 11:43:28 lsmith Exp $ // /** @@ -62,11 +62,12 @@ // {{{ constructor /** - * Constructor - */ - function MDB2_Driver_mssql() + * Constructor + */ + function __construct() { - $this->MDB2_Driver_Common(); + parent::__construct(); + $this->phptype = 'mssql'; $this->dbsyntax = 'mssql'; @@ -87,6 +88,11 @@ $db->options['database_size'] = false; } + function MDB2_Driver_mssql() + { + $this->__construct(); + } + // }}} // {{{ errorInfo() @@ -100,10 +106,12 @@ function errorInfo($error = null) { $native_code = null; - $result = @mssql_query('select @@ERROR as ErrorCode', $this->connection); - if ($result) { - $native_code = @mssql_result($result); - @mssql_free_result($result); + if ($this->connection) { + $result = @mssql_query('select @@ERROR as ErrorCode', $this->connection); + if ($result) { + $native_code = @mssql_result($result); + @mssql_free_result($result); + } } $native_msg = @mssql_get_last_message(); if (is_null($error)) { @@ -284,7 +292,6 @@ $port = $dsninfo['port'] ? ':' . $dsninfo['port'] : ''; $dbhost .= $port; - @ini_set('track_errors', true); if ($dbhost && $user && $pw) { $connection = @$function($dbhost, $user, $pw); } elseif ($dbhost && $user) { @@ -294,10 +301,8 @@ } else { $connection = 0; } - @ini_restore('track_errors'); if ($connection <= 0) { - return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, - $php_errormsg); + return $this->raiseError(MDB2_ERROR_CONNECT_FAILED); } $this->connection = $connection; $this->connected_dsn = $this->dsn; @@ -537,18 +542,6 @@ class MDB2_Result_mssql extends MDB2_Result_Common { - // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_Result_mssql(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_Common($mdb, $result, $offset, $limit); - } - - // }}} // {{{ _skipLimitOffset() /** @@ -763,18 +756,6 @@ class MDB2_BufferedResult_mssql extends MDB2_Result_mssql { - // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_BufferedResult_mssql(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_mssql($mdb, $result, $offset, $limit); - } - - // }}} // {{{ valid() /** http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/mysql.php?r1=1.20&r2=1.21&ty=u Index: pear/MDB2/MDB2/Driver/mysql.php diff -u pear/MDB2/MDB2/Driver/mysql.php:1.20 pear/MDB2/MDB2/Driver/mysql.php:1.21 --- pear/MDB2/MDB2/Driver/mysql.php:1.20 Wed May 12 09:00:09 2004 +++ pear/MDB2/MDB2/Driver/mysql.php Fri May 21 07:43:28 2004 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.20 2004/05/12 13:00:09 lsmith Exp $ +// $Id: mysql.php,v 1.21 2004/05/21 11:43:28 lsmith Exp $ // /** @@ -66,9 +66,10 @@ /** * Constructor */ - function MDB2_Driver_mysql() + function __construct() { - $this->MDB2_Driver_Common(); + parent::__construct(); + $this->phptype = 'mysql'; $this->dbsyntax = 'mysql'; @@ -87,6 +88,11 @@ $this->options['default_table_type'] = false; } + function MDB2_Driver_mysql() + { + $this->__construct(); + } + // }}} // {{{ errorInfo() @@ -99,8 +105,13 @@ */ function errorInfo($error = null) { - $native_code = @mysql_errno($this->connection); - $native_msg = @mysql_error($this->connection); + if($this->connection) { + $native_code = @mysql_errno($this->connection); + $native_msg = @mysql_error($this->connection); + } else { + $native_code = @mysql_errno(); + $native_msg = @mysql_error(); + } if (is_null($error)) { static $ecode_map; if (empty($ecode_map)) { @@ -319,12 +330,9 @@ $user = $dsninfo['username']; $pw = $dsninfo['password']; - @ini_set('track_errors', true); $connection = @$function($dbhost, $user, $pw, true); - @ini_restore('track_errors'); if ($connection <= 0) { - return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, - $php_errormsg); + return $this->raiseError(MDB2_ERROR_CONNECT_FAILED); } $this->connection = $connection; $this->connected_dsn = $this->dsn; @@ -746,17 +754,6 @@ class MDB2_Result_mysql extends MDB2_Result_Common { // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_Result_mysql(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_Common($mdb, $result, $offset, $limit); - } - - // }}} // {{{ fetch() /** @@ -924,17 +921,6 @@ class MDB2_BufferedResult_mysql extends MDB2_Result_mysql { // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_BufferedResult_mysql(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_mysql($mdb, $result, $offset, $limit); - } - - // }}} // {{{ seek() /** http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/pgsql.php?r1=1.17&r2=1.18&ty=u Index: pear/MDB2/MDB2/Driver/pgsql.php diff -u pear/MDB2/MDB2/Driver/pgsql.php:1.17 pear/MDB2/MDB2/Driver/pgsql.php:1.18 --- pear/MDB2/MDB2/Driver/pgsql.php:1.17 Wed May 12 09:00:10 2004 +++ pear/MDB2/MDB2/Driver/pgsql.php Fri May 21 07:43:28 2004 @@ -43,7 +43,7 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.17 2004/05/12 13:00:10 lsmith Exp $ +// $Id: pgsql.php,v 1.18 2004/05/21 11:43:28 lsmith Exp $ /** * MDB2 PostGreSQL driver @@ -63,9 +63,10 @@ /** * Constructor */ - function MDB2_Driver_pgsql() + function __construct() { - $this->MDB2_Driver_Common(); + parent::__construct(); + $this->phptype = 'pgsql'; $this->dbsyntax = 'pgsql'; @@ -83,6 +84,11 @@ $this->supported['auto_increment'] = false; } + function MDB2_Driver_pgsql() + { + $this->__construct(); + } + // }}} // {{{ errorInfo() @@ -97,8 +103,10 @@ { if (is_resource($error)) { $native_msg = @pg_result_error($error); - } else { + } elseif($this->connection) { $native_msg = @pg_errormessage($this->connection); + } else { + $native_msg = @pg_errormessage(); } // Fall back to MDB2_ERROR if there was no mapping. @@ -260,20 +268,12 @@ putenv('PGDATESTYLE=ISO'); $function = ($persistent ? 'pg_pconnect' : 'pg_connect'); - // catch error - ob_start(); $connection = @$function($connstr); - $error_msg = ob_get_contents(); - ob_end_clean(); if ($connection > 0) { return $connection; } - if (!$error_msg) { - $error_msg = 'Could not connect to PostgreSQL server'; - } - return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, - $error_msg); + return $this->raiseError(MDB2_ERROR_CONNECT_FAILED); } // }}} @@ -305,30 +305,6 @@ } if ($this->database_name) { - if (function_exists('pg_cmdtuples')) { - $connection = $this->_doConnect('template1', 0); - if (!MDB2::isError($connection)) { - if (($result = @pg_exec($connection, 'BEGIN'))) { - $error_reporting = error_reporting(63); - @pg_cmdtuples($result); - if (!isset($php_errormsg) - || strcmp($php_errormsg, 'This compilation does not support pg_cmdtuples()') - ) { - $this->supported['affected_rows'] = true; - } - error_reporting($error_reporting); - } else { - $err = $this->raiseError($result); - } - @pg_close($connection); - } else { - $err = $this->raiseError(MDB2_ERROR, null, null, - 'connect: could not execute BEGIN'); - } - if (isset($err) && MDB2::isError($err)) { - return $err; - } - } $connection = $this->_doConnect($this->database_name, $this->options['persistent']); if (MDB2::isError($connection)) { return $connection; @@ -389,7 +365,7 @@ { $result = @pg_exec($this->connection, $query); if ($result) { - $this->affected_rows = (isset($this->supported['affected_rows']) ? @pg_cmdtuples($result) : -1); + $this->affected_rows = (isset($this->supported['affected_rows']) ? @pg_affected_rows($result) : -1); } else { return $this->raiseError($result); } @@ -486,7 +462,7 @@ } if (!MDB2::isError($result)) { if ($ismanip) { - $this->affected_rows = @pg_cmdtuples($result); + $this->affected_rows = @pg_affected_rows($result); return MDB2_OK; } elseif ((preg_match('/^\s*\(?\s*SELECT\s+/si', $query) && !preg_match('/^\s*\(?\s*SELECT\s+INTO\s/si', $query)) @@ -572,18 +548,6 @@ class MDB2_Result_pgsql extends MDB2_Result_Common { - // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_Result_pgsql(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_Common($mdb, $result, $offset, $limit); - } - - // }}} // {{{ fetch() /** @@ -777,18 +741,6 @@ class MDB2_BufferedResult_pgsql extends MDB2_Result_pgsql { - // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_BufferedResult_pgsql(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_pgsql($mdb, $result, $offset, $limit); - } - - // }}} // {{{ seek() /** http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/querysim.php?r1=1.13&r2=1.14&ty=u Index: pear/MDB2/MDB2/Driver/querysim.php diff -u pear/MDB2/MDB2/Driver/querysim.php:1.13 pear/MDB2/MDB2/Driver/querysim.php:1.14 --- pear/MDB2/MDB2/Driver/querysim.php:1.13 Wed May 12 09:00:10 2004 +++ pear/MDB2/MDB2/Driver/querysim.php Fri May 21 07:43:28 2004 @@ -61,7 +61,7 @@ // | please contact Alan Richmond. | // +----------------------------------------------------------------------+ // -// $Id: querysim.php,v 1.13 2004/05/12 13:00:10 lsmith Exp $ +// $Id: querysim.php,v 1.14 2004/05/21 11:43:28 lsmith Exp $ // /* @@ -224,9 +224,10 @@ /** * Constructor */ - function MDB2_Driver_querysim() + function __construct() { - $this->MDB2_Driver_Common(); + parent::__construct(); + $this->phptype = 'querysim'; $this->dbsyntax = 'querysim'; @@ -248,6 +249,12 @@ $this->options['dataDelim'] = '|'; $this->options['eolDelim'] = "\n"; } + + function MDB2_Driver_querysim() + { + $this->__construct(); + } + // }}} // {{{ connect() @@ -538,18 +545,6 @@ class MDB2_Result_querysim extends MDB2_Result_Common { - // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_Result_querysim(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_Common($mdb, $result, $offset, $limit); - } - - // }}} // {{{ fetch() /** @@ -691,18 +686,6 @@ class MDB2_BufferedResult_querysim extends MDB2_Result_querysim { - // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_BufferedResult_querysim(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_querysim($mdb, $result, $offset, $limit); - } - - // }}} // {{{ seek() /** http://cvs.php.net/diff.php/pear/MDB2/MDB2/Driver/sqlite.php?r1=1.22&r2=1.23&ty=u Index: pear/MDB2/MDB2/Driver/sqlite.php diff -u pear/MDB2/MDB2/Driver/sqlite.php:1.22 pear/MDB2/MDB2/Driver/sqlite.php:1.23 --- pear/MDB2/MDB2/Driver/sqlite.php:1.22 Wed May 12 09:00:10 2004 +++ pear/MDB2/MDB2/Driver/sqlite.php Fri May 21 07:43:28 2004 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: sqlite.php,v 1.22 2004/05/12 13:00:10 lsmith Exp $ +// $Id: sqlite.php,v 1.23 2004/05/21 11:43:28 lsmith Exp $ // /** @@ -68,9 +68,10 @@ /** * Constructor */ - function MDB2_Driver_sqlite() + function __construct() { - $this->MDB2_Driver_Common(); + parent::__construct(); + $this->phptype = 'sqlite'; $this->dbsyntax = 'sqlite'; @@ -93,6 +94,11 @@ $this->options['database_extension'] = ''; } + function MDB2_Driver_sqlite() + { + $this->__construct(); + } + // }}} // {{{ errorInfo() @@ -105,7 +111,10 @@ */ function errorInfo($error = null) { - $native_code = @sqlite_last_error($this->connection); + $native_code = null; + if ($this->connection) { + $native_code = @sqlite_last_error($this->connection); + } $native_msg = @sqlite_error_string($native_code); if (is_null($error)) { @@ -331,7 +340,7 @@ $function = ($this->options['persistent'] ? 'sqlite_popen' : 'sqlite_open'); $connection = @$function($database_file); if (!$connection) { - return $this->raiseError(); + return $this->raiseError(MDB2_ERROR_CONNECT_FAILED); } $this->connection = $connection; $this->connected_dsn = $this->dsn; @@ -687,18 +696,6 @@ class MDB2_Result_sqlite extends MDB2_Result_Common { - // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_Result_sqlite(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_Common($mdb, $result, $offset, $limit); - } - - // }}} // {{{ fetch() /** @@ -837,18 +834,6 @@ class MDB2_BufferedResult_sqlite extends MDB2_Result_sqlite { - // }}} - // {{{ constructor - - /** - * Constructor - */ - function MDB2_BufferedResult_sqlite(&$mdb, &$result, $offset, $limit) - { - parent::MDB2_Result_sqlite($mdb, $result, $offset, $limit); - } - - // }}} // {{{ seek() /**
« previous php.pear.cvs (#19727) next »