cvs: php4 /pear DB.php /pear/DB STATUS common.php ibase.php msql.php mssql.php mysql.php oci8.php odbc.php pgsql.php sybase.php

From: Date: Fri, 08 Dec 2000 02:30:44 +0000
Subject: cvs: php4 /pear DB.php /pear/DB STATUS common.php ibase.php msql.php mssql.php mysql.php oci8.php odbc.php pgsql.php sybase.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-3020@lists.php.net to get a copy of this message
ssb Thu Dec 7 18:30:44 2000 EDT Modified files: /php4/pear DB.php /php4/pear/DB STATUS common.php ibase.php msql.php mssql.php mysql.php oci8.php odbc.php pgsql.php sybase.php Log: * applied fetch modes patch for odbc by Richard M. Yumul * added DB::isManip so we have _one_ place for testing whether something is a data manipulation query * when passed a string as its first constructor arg, DB_Error now uses the error code DB_ERROR rather than just 0 * implemented auto-commit for ibase (not yet fully tested) * fixed persistent connections in odbc

Index: php4/pear/DB.php diff -u php4/pear/DB.php:1.40 php4/pear/DB.php:1.41 --- php4/pear/DB.php:1.40 Thu Dec 7 11:53:27 2000 +++ php4/pear/DB.php Thu Dec 7 18:30:43 2000 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: DB.php,v 1.40 2000/12/07 19:53:27 ssb Exp $ +// $Id: DB.php,v 1.41 2000/12/08 02:30:43 ssb Exp $ // // Database independent query interface. // @@ -248,6 +248,24 @@ } /** + * Tell whether a query is a data manipulation query (insert, update + * or delete). + * + * @access public + * + * @param string the query + * + * @return bool whether $query is a data manipulation query + */ + function isManip($query) + { + if (preg_match('/^\s*(INSERT|UPDATE|DELETE)\s+/i', $query)) { + return true; + } + return false; + } + + /** * Tell whether a result code from a DB method is a warning. * Warnings differ from errors in that they are generated by DB, * and are not fatal. @@ -437,7 +455,7 @@ if (is_int($code)) { $this->PEAR_Error("DB Error: " . DB::errorMessage( $code ), $code, $mode, $level, $debuginfo); } else { - $this->PEAR_Error("DB Error: $code", 0, $mode, $level, $debuginfo); + $this->PEAR_Error("DB Error: $code", DB_ERROR, $mode, $level, $debuginfo); } } } Index: php4/pear/DB/STATUS diff -u php4/pear/DB/STATUS:1.5 php4/pear/DB/STATUS:1.6 --- php4/pear/DB/STATUS:1.5 Thu Dec 7 12:11:02 2000 +++ php4/pear/DB/STATUS Thu Dec 7 18:30:43 2000 @@ -20,3 +20,4 @@ affectedRows - - - X x - x - fetch modes x x x X x - x x transactions n n n n x - n n +auto-commit x \ No newline at end of file Index: php4/pear/DB/common.php diff -u php4/pear/DB/common.php:1.28 php4/pear/DB/common.php:1.29 --- php4/pear/DB/common.php:1.28 Tue Dec 5 18:53:15 2000 +++ php4/pear/DB/common.php Thu Dec 7 18:30:43 2000 @@ -39,7 +39,7 @@ var $error_level = E_USER_NOTICE; var $error_callback; var $last_query = ''; - var $fetchmode = DB_FETCHMODE_DEFAULT; + var $fetchmode = DB_FETCHMODE_ORDERED; var $seq_table = "db_sequence"; // }}} @@ -285,7 +285,7 @@ /** * Prepares a query for multiple execution with execute(). With - * PostgreSQL, this is emulated. + * some database backends, this is emulated. */ function prepare($query) Index: php4/pear/DB/ibase.php diff -u php4/pear/DB/ibase.php:1.10 php4/pear/DB/ibase.php:1.11 --- php4/pear/DB/ibase.php:1.10 Tue Dec 5 18:53:15 2000 +++ php4/pear/DB/ibase.php Thu Dec 7 18:30:43 2000 @@ -16,7 +16,7 @@ // | Authors: Sterling Hughes <sterling@php.net> | // +----------------------------------------------------------------------+ // -// $Id: ibase.php,v 1.10 2000/12/06 02:53:15 ssb Exp $ +// $Id: ibase.php,v 1.11 2000/12/08 02:30:43 ssb Exp $ // // Database independent query interface definition for PHP's Interbase // extension. @@ -24,12 +24,15 @@ require_once 'DB/common.php'; -class DB_ibase extends DB_common { - +class DB_ibase extends DB_common +{ var $connection; var $phptype, $dbsyntax; + var $autocommit = 1; + var $manip_query = array(); - function DB_ibase() { + function DB_ibase() + { $this->phptype = 'ibase'; $this->dbsyntax = 'ibase'; $this->features = array( @@ -39,14 +42,15 @@ ); } - function connect (&$dsn, $persistant=false) { + function connect($dsn, $persistant = false) + { if(is_array($dsn)) { $dsninfo = &$dsn; } else { $dsninfo = DB::parseDSN($dsn); } if (!$dsninfo || !$dsninfo['phptype']) { - return $this->raiseError(); + return $this->raiseError("invalid data source name"); } $user = $dsninfo['username']; $pw = $dsninfo['password']; @@ -61,44 +65,49 @@ } elseif ($dbhost) { $conn = $connect_function($dbhost); } else { - return $this->raiseError(); + return $this->raiseError("no host, user or password"); } $this->connection = $conn; return DB_OK; } - function disconnect() { + function disconnect() + { return @ibase_close($this->connection); } - function &query( $stmt ) { + function &query($stmt) + { $this->last_query = $query; $result = @ibase_query($this->connection, $stmt); if (!$result) { return $this->raiseError(); } + if ($this->autocommit) { + ibase_commit($this->connection); + } // Determine which queries that should return data, and which // should return an error code only. - if (preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $stmt)) { - $resultObj = new DB_result($this, $result); - return $resultObj; - } else { - return DB_OK; - } + return DB::isManip($stmt) ? DB_OK : new DB_result($this, $result); } - function simpleQuery($stmt) { + function simpleQuery($stmt) + { $this->last_query = $query; $result = @ibase_query($this->connection, $stmt); if (!$result) { return $this->raiseError(); } + if ($this->autocommit) { + ibase_commit($this->connection); + } // Determine which queries that should return data, and which // should return an error code only. - return preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $stmt) ? $result : DB_OK; + return DB::isManip($stmt) ? DB_OK : $result; } - function &fetchRow($result, $fetchmode=DB_FETCHMODE_DEFAULT) { + function &fetchRow($result, $fetchmode=DB_FETCHMODE_DEFAULT) + { if ($fetchmode == DB_FETCHMODE_DEFAULT) { $fetchmode = $this->fetchmode; } @@ -113,7 +122,8 @@ return $row; } - function fetchInto($result, &$ar, $fetchmode=DB_FETCHMODE_DEFAULT) { + function fetchInto($result, &$ar, $fetchmode=DB_FETCHMODE_DEFAULT) + { if ($fetchmode == DB_FETCHMODE_DEFAULT) { $fetchmode = $this->fetchmode; } @@ -128,16 +138,19 @@ return DB_OK; } - function freeResult() { + function freeResult() + { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } - function freeQuery($query) { + function freeQuery($query) + { ibase_free_query($query); return true; } - function numCols($result) { + function numCols($result) + { $cols = ibase_num_fields($result); if (!$cols) { return $this->raiseError(); @@ -145,32 +158,44 @@ return $cols; } - function prepare($query) { + function prepare($query) + { $this->last_query = $query; - return ibase_prepare($query); + $stmt = ibase_prepare($query); + $this->manip_query[(int)$stmt] = DB::isManip($query); + return $stmt; } - function execute($stmt, $data = false) { + function execute($stmt, $data = false) + { $result = ibase_execute($stmt, $data); if (!$result) { return $this->raiseError(); } - return preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $stmt) ? $result : DB_OK; + if ($this->autocommit) { + ibase_commit($this->connection); + } + return DB::isManip($this->manip_query[(int)$stmt]) ? DB_OK : $result; } - function autoCommit($onoff=false) { - return $this->raiseError(DB_ERROR_NOT_CAPABLE); + function autoCommit($onoff = false) + { + $this->autocommit = $onoff ? 1 : 0; + return DB_OK; } - function commit() { + function commit() + { return ibase_commit($this->connection); } - function rollback($trans_number) { - return ibase_rollback($this->connection,$trans_number); + function rollback($trans_number) + { + return ibase_rollback($this->connection, $trans_number); } - function transactionInit($trans_args=0) { + function transactionInit($trans_args = 0) + { return $trans_args ? ibase_trans($trans_args, $this->connection) : ibase_trans(); } } Index: php4/pear/DB/msql.php diff -u php4/pear/DB/msql.php:1.9 php4/pear/DB/msql.php:1.10 --- php4/pear/DB/msql.php:1.9 Wed Sep 13 04:27:59 2000 +++ php4/pear/DB/msql.php Thu Dec 7 18:30:43 2000 @@ -16,7 +16,7 @@ // | Authors: Sterling Hughes <sterling@php.net> | // +----------------------------------------------------------------------+ // -// $Id: msql.php,v 1.9 2000/09/13 11:27:59 ssb Exp $ +// $Id: msql.php,v 1.10 2000/12/08 02:30:43 ssb Exp $ // // Database independent query interface definition for PHP's Mini-SQL // extension. @@ -41,7 +41,7 @@ ); } - function connect (&$dsn, $persistent=false) { + function connect($dsn, $persistent = false) { if(is_array($dsn)) { $dsninfo = &$dsn; } else { @@ -83,12 +83,7 @@ } // Determine which queries that should return data, and which // should return an error code only. - if (preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $stmt)) { - $resultObj = new DB_result($this, $result); - return $resultObj; - } else { - return DB_OK; - } + return DB::isManip($stmt) ? DB_OK : new DB_result($this, $result); } function simpleQuery($stmt) { @@ -99,11 +94,7 @@ } // Determine which queries that should return data, and which // should return an error code only. - if ( preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $stmt) ) { - return $result; - } else { - return DB_OK; - } + return DB::isManip($stmt) ? DB_OK : $result; } function &fetchRow($result, $fetchmode=DB_FETCHMODE_DEFAULT) { @@ -183,12 +174,8 @@ $result = @msql_query($realquery, $this->connection); if (!$result) { return $this->raiseError(); - } - if ( preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $realquery) ) { - return $result; - } else { - return DB_OK; } + return DB::isManip($realquery) ? DB_OK : $result; } function autoCommit($onoff=false) { Index: php4/pear/DB/mssql.php diff -u php4/pear/DB/mssql.php:1.12 php4/pear/DB/mssql.php:1.13 --- php4/pear/DB/mssql.php:1.12 Wed Sep 13 04:27:59 2000 +++ php4/pear/DB/mssql.php Thu Dec 7 18:30:43 2000 @@ -16,7 +16,7 @@ // | Authors: Sterling Hughes <sterling@php.net> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.12 2000/09/13 11:27:59 ssb Exp $ +// $Id: mssql.php,v 1.13 2000/12/08 02:30:43 ssb Exp $ // // Database independent query interface definition for PHP's Microsoft SQL Server // extension. @@ -41,7 +41,7 @@ ); } - function connect (&$dsn, $persistent=false) { + function connect($dsn, $persistent = false) { if(is_array($dsn)) { $dsninfo = &$dsn; } else { @@ -83,12 +83,7 @@ } // Determine which queries that should return data, and which // should return an error code only. - if (preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $stmt)) { - $resultObj = new DB_result($this, $result); - return $resultObj; - } else { - return DB_OK; - } + return DB::isManip($stmt) ? DB_OK : new DB_result($this, $result); } function simpleQuery($stmt) { @@ -99,11 +94,7 @@ } // Determine which queries that should return data, and which // should return an error code only. - if ( preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $stmt) ) { - return $result; - } else { - return DB_OK; - } + return DB::isManip($stmt) ? DB_OK : $result; } function &fetchRow($result, $fetchmode=DB_FETCHMODE_DEFAULT) { @@ -183,12 +174,8 @@ $result = @mssql_query($realquery, $this->connection); if (!$result) { return $this->raiseError(); - } - if ( preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $realquery) ) { - return $result; - } else { - return DB_OK; } + return DB::isManip($realquery) ? DB_OK : $result; } function autoCommit($onoff=false) { Index: php4/pear/DB/mysql.php diff -u php4/pear/DB/mysql.php:1.34 php4/pear/DB/mysql.php:1.35 --- php4/pear/DB/mysql.php:1.34 Thu Dec 7 16:24:28 2000 +++ php4/pear/DB/mysql.php Thu Dec 7 18:30:43 2000 @@ -87,7 +87,7 @@ * @return int DB_OK on success, a DB error on failure */ - function connect(&$dsn, $persistent = false) { + function connect($dsn, $persistent = false) { if (is_array($dsn)) { $dsninfo = &$dsn; } else { @@ -166,11 +166,7 @@ // Determine which queries that should return data, and which // should return an error code only. - if (preg_match("/(SELECT|SHOW)/i", $query)) { - return new DB_result($this, $result); - } else { - return DB_OK; - } + return DB::isManip($query) ? DB_OK : new DB_result($this, $result); } // }}} @@ -198,11 +194,7 @@ // Determine which queries that should return data, and which // should return an error code only. - if (preg_match("/(SELECT|SHOW)/i", $query)) { - return $result; - } else { - return DB_OK; - } + return DB::isManip($query) ? DB_OK : $result; } // }}} @@ -453,18 +445,11 @@ function execute($stmt, $data = false) { $realquery = $this->execute_emulate_query($stmt, $data); $this->last_query = $realquery; - $result = mysql_query($realquery, $this->connection); - if (!$result) { return $this->raiseError($this->errorCode(mysql_errno($this->connection))); - } - - if (preg_match("/(SELECT|SHOW)/i", $realquery)) { - return $result; - } else { - return DB_OK; } + return DB::isManip($realquery) ? DB_OK : $result; } // }}} Index: php4/pear/DB/oci8.php diff -u php4/pear/DB/oci8.php:1.9 php4/pear/DB/oci8.php:1.10 --- php4/pear/DB/oci8.php:1.9 Wed Sep 13 04:27:59 2000 +++ php4/pear/DB/oci8.php Thu Dec 7 18:30:43 2000 @@ -35,7 +35,7 @@ var $connection; var $phptype, $dbsyntax; - var $select_query = array(); + var $manip_query = array(); var $prepare_types = array(); var $autoCommit = 1; var $last_stmt = false; @@ -68,7 +68,7 @@ * * @return int DB_OK on success, a DB error code on failure */ - function connect(&$dsn, $persistent = false) { + function connect($dsn, $persistent = false) { if (is_array($dsn)) { $dsninfo = &$dsn; } else { @@ -138,12 +138,7 @@ $this->last_stmt=$result; // Determine which queries that should return data, and which // should return an error code only. - if (preg_match('/(SELECT|SHOW)/i', $query)) { - $resultObj = new DB_result($this, $result); - return $resultObj; - } else { - return DB_OK; - } + return DB::isManip($query) ? DB_OK : new DB_result($this, $result); } // }}} @@ -177,11 +172,7 @@ $this->last_stmt=$result; // Determine which queries that should return data, and which // should return an error code only. - if (preg_match('/(SELECT|SHOW)/i', $query)) { - return $result; - } else { - return DB_OK; - } + return DB::isManip($query) ? DB_OK : $result; } // }}} @@ -332,7 +323,7 @@ $this->last_query = $query; $stmt=OCIParse($this->connection,$newquery); $this->prepare_types[$stmt] = $types; - $this->select_query[$stmt] = preg_match('/(SELECT|SHOW)/i', $newquery); + $this->manip_query[$stmt] = DB::isManip($newquery); return $stmt; } @@ -384,11 +375,10 @@ return $this->raiseError(); } $this->last_stmt=$stmt; - if ($this->select_query[$stmt]) { - return $stmt; - } - else { + if ($this->manip_query[$stmt]) { return $DB_OK; + } else { + return $stmt; } } Index: php4/pear/DB/odbc.php diff -u php4/pear/DB/odbc.php:1.16 php4/pear/DB/odbc.php:1.17 --- php4/pear/DB/odbc.php:1.16 Wed Sep 13 04:27:59 2000 +++ php4/pear/DB/odbc.php Thu Dec 7 18:30:43 2000 @@ -93,7 +93,7 @@ * * @return int DB_OK on success, a DB error code on failure */ - function connect(&$dsn, $user, $pw) { + function connect($dsn, $persistent = false) { if (is_array($dsn)) { $dsninfo = &$dsn; } else { @@ -162,12 +162,7 @@ } // Determine which queries that should return data, and which // should return an error code only. - if (preg_match('/SELECT/i', $query)) { - $resultObj = new DB_result($this, $result); - return $resultObj; // XXX ADDREF - } else { - return DB_OK; - } + return DB::isManip($query) ? DB_OK : new DB_result($this, $result); } // }}} @@ -191,23 +186,42 @@ } // Determine which queries that should return data, and which // should return an error code only. - if (preg_match('/SELECT/i', $query)) { - return $result; - } else { - return DB_OK; - } + return DB::isManip($query) ? DB_OK : $result; } // }}} // {{{ fetchRow() - function fetchRow($result) { + /** + * Fetch a row and return as array. + * + * @param $result result identifier + * @param $fetchmode how the resulting array should be indexed + * + * @return mixed an array on success (associative or ordred, depending on + * fetchmode), a false on failure, false if there is no more + * data + */ + function fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT) + { + if ($fetchmode == DB_FETCHMODE_DEFAULT) { + $fetchmode = $this->fetchmode; + } $cols = odbc_fetch_into($result, &$row); if ($cols == 0) { - // XXX ERRORMSG - return false; + return $this->raiseError(); // XXX ERRORMSG } - return $row; // XXX ADDREF + if ($fetchmode == DB_FETCHMODE_ORDERED) { + return $row; + } else if ($fetchmode == DB_FETCHMODE_ASSOC) { + for ($i = 0; $i < count($row); $i++) { + $colName = odbc_field_name($result, $i+1); + $a[$colName] = $row[$i]; + } + return $a; + } else { + return $this->raiseError(); // XXX ERRORMSG + } } // }}} Index: php4/pear/DB/pgsql.php diff -u php4/pear/DB/pgsql.php:1.16 php4/pear/DB/pgsql.php:1.17 --- php4/pear/DB/pgsql.php:1.16 Thu Dec 7 07:39:29 2000 +++ php4/pear/DB/pgsql.php Thu Dec 7 18:30:43 2000 @@ -72,7 +72,7 @@ * * @return int DB_OK on success, a DB error code on failure */ - function connect(&$dsn, $persistent = false) { + function connect($dsn, $persistent = false) { if (is_array($dsn)) { $dsninfo = &$dsn; } else { @@ -150,14 +150,14 @@ } // Determine which queries that should return data, and which // should return an error code only. - if (preg_match('/(SELECT|SHOW)/i', $query)) { + if (DB::isManip($query)) { + $this->affected = pg_cmdtuples($result); + return DB_OK; + } elseif (preg_match('/^\s*(SELECT|SHOW)\s+/i', $query)) { $resultObj = new DB_result($this, $result); $this->row[$result] = 0; // reset the row counter. $this->numrows[$result] = pg_numrows($result); return $resultObj; - } elseif (preg_match('/(INSERT|UPDATE|DELETE)/i', $query)) { - $this->affected = pg_cmdtuples($result); - return DB_OK; } else { return DB_OK; } @@ -184,13 +184,13 @@ } // Determine which queries that should return data, and which // should return an error code only. - if (preg_match('/(SELECT|SHOW)/i', $query)) { + if (DB::isManip($query)) { + $this->affected = pg_cmdtuples($result); + return DB_OK; + } elseif (preg_match('/(SELECT|SHOW)/i', $query)) { $this->row[$result] = 0; // reset the row counter. $this->numrows[$result] = pg_numrows($result); return $result; - } elseif (preg_match('/(INSERT|UPDATE|DELETE)/i', $query)) { - $this->affected = pg_cmdtuples($result); - return DB_OK; } else { return DB_OK; } @@ -389,13 +389,13 @@ if (!$result) { return pg_errormessage($this->connection); } - if (preg_match('/(SELECT|SHOW)/i', $realquery)) { + if (DB::isManip($query)) { + $this->affected = pg_cmdtuples($result); + return DB_OK; + } elseif (preg_match('/(SELECT|SHOW)/i', $realquery)) { $this->row[$result] = 0; // reset the row counter. $this->numrows[$result] = pg_numrows($result); return $result; - } elseif (preg_match('/(INSERT|UPDATE|DELETE)/i', $realquery)) { - $this->affected = pg_cmdtuples($result); - return DB_OK; } else { return DB_OK; } Index: php4/pear/DB/sybase.php diff -u php4/pear/DB/sybase.php:1.8 php4/pear/DB/sybase.php:1.9 --- php4/pear/DB/sybase.php:1.8 Wed Sep 13 04:27:59 2000 +++ php4/pear/DB/sybase.php Thu Dec 7 18:30:43 2000 @@ -16,7 +16,7 @@ // | Authors: Sterling Hughes <sterling@php.net> | // +----------------------------------------------------------------------+ // -// $Id: sybase.php,v 1.8 2000/09/13 11:27:59 ssb Exp $ +// $Id: sybase.php,v 1.9 2000/12/08 02:30:43 ssb Exp $ // // Database independent query interface definition for PHP's Sybase // extension. @@ -24,14 +24,15 @@ require_once 'DB/common.php'; -class DB_sybase extends DB_common { - +class DB_sybase extends DB_common +{ var $connection; var $phptype, $dbsyntax; var $prepare_tokens = array(); var $prepare_types = array(); - function DB_sybase() { + function DB_sybase() + { $this->phptype = 'sybase'; $this->dbsyntax = 'sybase'; $this->features = array( @@ -41,7 +42,8 @@ ); } - function connect ( $dsn, $persistent=false ) { + function connect($dsn, $persistent = false) + { if(is_array($dsn)) { $dsninfo = &$dsn; } else { @@ -58,11 +60,13 @@ return DB_OK; } - function disconnect() { + function disconnect() + { return @sybase_close($this->connection); } - function &query( $stmt ) { + function &query($stmt) + { $this->last_query = $stmt; $result = @sybase_query($stmt, $this->connection); if (!$result) { @@ -70,15 +74,11 @@ } // Determine which queries that should return data, and which // should return an error code only. - if (preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $stmt)) { - $resultObj = new DB_result($this, $result); - return $resultObj; - } else { - return DB_OK; - } + return DB::isManip($stmt) ? DB_OK : new DB_result($this, $result); } - function simpleQuery($stmt) { + function simpleQuery($stmt) + { $this->last_query = $stmt; $result = @sybase_query($stmt, $this->connection); if (!$result) { @@ -86,10 +86,11 @@ } // Determine which queries that should return data, and which // should return an error code only. - return preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $stmt) ? $result : DB_OK; + return DB::isManip($stmt) ? DB_OK : $result; } - function &fetchRow($result, $fetchmode=DB_FETCHMODE_DEFAULT) { + function &fetchRow($result, $fetchmode=DB_FETCHMODE_DEFAULT) + { if ($fetchmode == DB_FETCHMODE_DEFAULT) { $fetchmode = $this->fetchmode; } @@ -100,7 +101,8 @@ return $row; } - function fetchInto($result, &$ar, $fetchmode=DB_FETCHMODE_DEFAULT) { + function fetchInto($result, &$ar, $fetchmode=DB_FETCHMODE_DEFAULT) + { if ($fetchmode == DB_FETCHMODE_DEFAULT) { $fetchmode = $this->fetchmode; } @@ -111,7 +113,8 @@ return DB_OK; } - function freeResult($result) { + function freeResult($result) + { if (is_resource($result)) { return @sybase_free_result($result); } @@ -123,7 +126,8 @@ return true; } - function numCols($result) { + function numCols($result) + { $cols = @sybase_num_fields($result); if (!$cols) { return $this->raiseError(); @@ -131,7 +135,8 @@ return $cols; } - function prepare($query) { + function prepare($query) + { $tokens = split('[\&\?]', $query); $token = 0; $types = array(); @@ -152,25 +157,29 @@ return $k; } - function execute($stmt, $data = false) { + function execute($stmt, $data = false) + { $realquery = $this->execute_emulate_query($stmt, $data); $this->last_query = $realquery; $result = @sybase_query($realquery, $this->connection); if (!$result) { return $this->raiseError(); } - return preg_match('/(SELECT|SHOW|LIST|DESCRIBE)/i', $realquery) ? $result : DB_OK; + return DB::isManip($realquery) ? DB_OK : $result; } - function autoCommit($onoff=false) { + function autoCommit($onoff = false) + { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } - function commit() { + function commit() + { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } - function rollback() { + function rollback() + { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } }
« previous php.cvs (#3020) next »