cvs: php4 /pear DB.php PEAR.php.in /pear/DB ibase.php msql.php mssql.php odbc.php sybase.php /pear/File Find.php
| From: | Sterling Hughes | Date: | Thu, 24 Aug 2000 01:34:16 +0000 |
| Subject: | cvs: php4 /pear DB.php PEAR.php.in /pear/DB ibase.php msql.php mssql.php odbc.php sybase.php /pear/File Find.php | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-1350@lists.php.net to get a copy of this message | ||
sterling Wed Aug 23 18:34:16 2000 EDT
Modified files:
/php4/pear DB.php PEAR.php.in
/php4/pear/DB ibase.php msql.php mssql.php odbc.php sybase.php
/php4/pear/File Find.php
Log:
-Add getCode() method to PEAR_Error
-Correct license versions + My Address for DB/* mods
-Correct ibase module
-Javadocize File_Find
-Add a optional constructor to DB that passes it on to DB::connect()
Index: php4/pear/DB.php
diff -u php4/pear/DB.php:1.26 php4/pear/DB.php:1.27
--- php4/pear/DB.php:1.26 Mon Aug 21 07:37:47 2000
+++ php4/pear/DB.php Wed Aug 23 18:34:16 2000
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: DB.php,v 1.26 2000/08/21 14:37:47 chagenbu Exp $
+// $Id: DB.php,v 1.27 2000/08/24 01:34:16 sterling Exp $
//
// Database independent query interface.
//
@@ -152,6 +152,14 @@
* @since PHP 4.0
*/
class DB {
+
+ function DB ($dsn = false, $persistent = false)
+ {
+ if ($dsn) {
+ return DB::connect ($dsn, $persistent);
+ }
+ }
+
// {{{ factory()
/**
@@ -162,7 +170,7 @@
* @return object a newly created DB object, or a DB error code on
* error
*/
- function &factory($type) {
+ function &factory($type) {
@include_once("DB/${type}.php");
$classname = 'DB_' . $type;
$obj = @new $classname;
@@ -170,7 +178,7 @@
return new DB_Error(DB_ERROR_NOT_FOUND);
}
return $obj;
- }
+ }
// }}}
// {{{ connect()
Index: php4/pear/PEAR.php.in
diff -u php4/pear/PEAR.php.in:1.2 php4/pear/PEAR.php.in:1.3
--- php4/pear/PEAR.php.in:1.2 Sun Jul 30 10:41:31 2000
+++ php4/pear/PEAR.php.in Wed Aug 23 18:34:16 2000
@@ -17,7 +17,7 @@
// | Stig Bakken <ssb@fast.no> |
// +----------------------------------------------------------------------+
//
-// $Id: PEAR.php.in,v 1.2 2000/07/30 17:41:31 ssb Exp $
+// $Id: PEAR.php.in,v 1.3 2000/08/24 01:34:16 sterling Exp $
//
define('PEAR_ERROR_RETURN', 0);
@@ -143,6 +143,7 @@
var $mode = PEAR_ERROR_RETURN;
var $level = E_USER_NOTICE;
+ var $code = -1;
var $message = '';
@@ -204,6 +205,19 @@
$this->message . $this->error_append);
}
+
+ // }}}
+ // {{{ getCode()
+
+ /**
+ * Get error code from an error object
+ *
+ * @return int error code
+ */
+ function getCode ()
+ {
+ return ($this->code);
+ }
// }}}
// {{{ getType()
Index: php4/pear/DB/ibase.php
diff -u php4/pear/DB/ibase.php:1.4 php4/pear/DB/ibase.php:1.5
--- php4/pear/DB/ibase.php:1.4 Mon Aug 21 07:40:55 2000
+++ php4/pear/DB/ibase.php Wed Aug 23 18:34:16 2000
@@ -5,29 +5,24 @@
// +----------------------------------------------------------------------+
// | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
+// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt.
|
+// | http://www.php.net/license/2_02.txt.
|
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
-// | Authors: Sterling Hughes <sterling@designmultimedia.com> |
-// | |
+// | Authors: Sterling Hughes <sterling@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: ibase.php,v 1.4 2000/08/21 14:40:55 chagenbu Exp $
+// $Id: ibase.php,v 1.5 2000/08/24 01:34:16 sterling Exp $
//
// Database independent query interface definition for PHP's Interbase
// extension.
//
-if (!empty($GLOBALS['USED_PACKAGES']['DB/ibase'])) return;
-$GLOBALS['USED_PACKAGES']['DB/ibase'] = true;
-if (empty($GLOBALS['USED_PACKAGES']['DB/common'])) {
- include("DB/common.php");
-}
+include_once 'DB/common.php';
class DB_ibase extends DB_common {
@@ -73,11 +68,11 @@
}
function disconnect() {
- return ibase_close($this->connection);
+ return @ibase_close($this->connection);
}
function &query( $stmt ) {
- $result = ibase_query($stmt, $this->connection); // arg order are currently wrong but will be
correct by PHP4
+ $result = @ibase_query($this->connection, $stmt);
if (!$result) {
return new DB_Error();
}
@@ -92,7 +87,7 @@
}
function simpleQuery($stmt) {
- $result = ibase_query($stmt, $this->connection);
+ $result = @ibase_query($this->connection, $stmt);
if (!$result) {
return new DB_Error();
}
@@ -103,7 +98,7 @@
function &fetchRow($result, $getmode=DB_GETMODE_DEFAULT) {
if ($getmode & DB_GETMODE_ASSOC) {
- return new DB_Error(DB_ERROR_NOT_CAPABLE);
+ $row = (array)ibase_fetch_object($result);
} else {
$row = ibase_fetch_row($result);
}
Index: php4/pear/DB/msql.php
diff -u php4/pear/DB/msql.php:1.5 php4/pear/DB/msql.php:1.6
--- php4/pear/DB/msql.php:1.5 Mon Aug 21 07:40:55 2000
+++ php4/pear/DB/msql.php Wed Aug 23 18:34:16 2000
@@ -13,11 +13,10 @@
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
-// | Authors: Sterling Hughes <sterling@designmultimedia.com> |
-// | |
+// | Authors: Sterling Hughes <sterling@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: msql.php,v 1.5 2000/08/21 14:40:55 chagenbu Exp $
+// $Id: msql.php,v 1.6 2000/08/24 01:34:16 sterling Exp $
//
// Database independent query interface definition for PHP's Mini-SQL
// extension.
Index: php4/pear/DB/mssql.php
diff -u php4/pear/DB/mssql.php:1.8 php4/pear/DB/mssql.php:1.9
--- php4/pear/DB/mssql.php:1.8 Mon Aug 21 07:40:55 2000
+++ php4/pear/DB/mssql.php Wed Aug 23 18:34:16 2000
@@ -13,11 +13,10 @@
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
-// | Authors: Sterling Hughes <sterling@designmultimedia.com> |
-// | |
+// | Authors: Sterling Hughes <sterling@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: mssql.php,v 1.8 2000/08/21 14:40:55 chagenbu Exp $
+// $Id: mssql.php,v 1.9 2000/08/24 01:34:16 sterling Exp $
//
// Database independent query interface definition for PHP's Microsoft SQL Server
// extension.
Index: php4/pear/DB/odbc.php
diff -u php4/pear/DB/odbc.php:1.11 php4/pear/DB/odbc.php:1.12
--- php4/pear/DB/odbc.php:1.11 Mon Aug 21 07:40:55 2000
+++ php4/pear/DB/odbc.php Wed Aug 23 18:34:16 2000
@@ -14,7 +14,7 @@
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Stig Bakken <ssb@fast.no> |
-// | |
+// | Sterling Hughes <sterling@php.net> |
// +----------------------------------------------------------------------+
//
// Database independent query interface definition for PHP's ODBC
Index: php4/pear/DB/sybase.php
diff -u php4/pear/DB/sybase.php:1.4 php4/pear/DB/sybase.php:1.5
--- php4/pear/DB/sybase.php:1.4 Mon Aug 21 07:40:55 2000
+++ php4/pear/DB/sybase.php Wed Aug 23 18:34:16 2000
@@ -13,21 +13,16 @@
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
-// | Authors: Sterling Hughes <sterling@designmultimedia.com> |
-// | |
+// | Authors: Sterling Hughes <sterling@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: sybase.php,v 1.4 2000/08/21 14:40:55 chagenbu Exp $
+// $Id: sybase.php,v 1.5 2000/08/24 01:34:16 sterling Exp $
//
// Database independent query interface definition for PHP's Sybase
// extension.
//
-if (!empty($GLOBALS['USED_PACKAGES']['DB/sybase'])) return;
-$GLOBALS['USED_PACKAGES']['DB/sybase'] = true;
-if (empty($GLOBALS['USED_PACKAGES']['DB/common'])) {
- include("DB/common.php");
-}
+include_once 'DB/common.php';
class DB_sybase extends DB_common {
@@ -46,7 +41,7 @@
);
}
- function connect (&$dsn, $persistant=false) {
+ function connect ( $dsn, $persistent=false ) {
if(is_array($dsn)) {
$dsninfo = &$dsn;
} else {
@@ -58,17 +53,17 @@
$dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] :
'localhost';
$connect_function = $persistent ? 'sybase_pconnect' : 'sybase_connect';
$conn = $dbhost ? $connect_function($dbhost) : false;
- $dsninfo['database'] && sybase_select_db($dsninfo['database'],
$conn);
+ $dsninfo['database'] && @sybase_select_db($dsninfo['database'],
$conn);
$this->connection = $conn;
return DB_OK;
}
function disconnect() {
- return sybase_close($this->connection);
+ return @sybase_close($this->connection);
}
function &query( $stmt ) {
- $result = sybase_query($stmt, $this->connection);
+ $result = @sybase_query($stmt, $this->connection);
if (!$result) {
return new DB_Error();
}
@@ -83,7 +78,7 @@
}
function simpleQuery($stmt) {
- $result = sybase_query($stmt, $this->connection);
+ $result = @sybase_query($stmt, $this->connection);
if (!$result) {
return new DB_Error();
}
@@ -93,7 +88,7 @@
}
function &fetchRow($result, $getmode=DB_GETMODE_DEFAULT) {
- $row = ($getmode & DB_GETMODE_ASSOC) ? sybase_fetch_array($result) :
sybase_fetch_row($result);
+ $row = ($getmode & DB_GETMODE_ASSOC) ? @sybase_fetch_array($result) :
@sybase_fetch_row($result);
if (!$row) {
return new DB_Error();
}
@@ -101,7 +96,7 @@
}
function fetchInto($result, &$ar, $getmode=DB_GETMODE_DEFAULT) {
- $ar = ($getmode & DB_GETMODE_ASSOC) ? sybase_fetch_array($result) :
sybase_fetch_row($result);
+ $ar = ($getmode & DB_GETMODE_ASSOC) ? @sybase_fetch_array($result) :
@sybase_fetch_row($result);
if (!$ar) {
return new DB_Error();
}
@@ -110,7 +105,7 @@
function freeResult($result) {
if (is_resource($result)) {
- return sybase_free_result($result);
+ return @sybase_free_result($result);
}
if (!isset($this->prepare_tokens[$result])) {
return false;
@@ -121,7 +116,7 @@
}
function numCols($result) {
- $cols = sybase_num_fields($result);
+ $cols = @sybase_num_fields($result);
if (!$cols) {
return new DB_Error();
}
@@ -151,7 +146,7 @@
function execute($stmt, $data = false) {
$realquery = $this->execute_emulate_query($stmt, $data);
- $result = sybase_query($realquery, $this->connection);
+ $result = @sybase_query($realquery, $this->connection);
if (!$result) {
return new DB_Error();
}
Index: php4/pear/File/Find.php
diff -u php4/pear/File/Find.php:1.9 php4/pear/File/Find.php:1.10
--- php4/pear/File/Find.php:1.9 Mon Jul 24 01:05:51 2000
+++ php4/pear/File/Find.php Wed Aug 23 18:34:16 2000
@@ -16,7 +16,7 @@
// | Authors: Sterling Hughes <sterling@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Find.php,v 1.9 2000/07/24 08:05:51 ssb Exp $
+// $Id: Find.php,v 1.10 2000/08/24 01:34:16 sterling Exp $
//
// Commonly needed functions searching directory trees
//
@@ -29,12 +29,24 @@
var $files = array ();
var $directories = array ();
- /*
- * array glob ( string pattern, string directory_path[, string pattern_type])
- * will search the current directory to find matches for the specified pattern.
- * It only searches the current directory and directory names are included in the
- * search. If you are looking to search a directory tree then see the search
- * method.
+ /**
+ * Search the current directory to find matches for the
+ * the specified pattern.
+ *
+ * @param $pattern a string containing the pattern to search
+ * the directory for.
+ *
+ * @param $direct_path a string containing the directory path
+ * to search.
+ *
+ * @param $pattern_type a string containing the type of
+ * pattern matching functions to use (can either be 'php' or
+ * 'perl').
+ *
+ * @return an array containing all of the files and directories
+ * matching the pattern.
+ *
+ * @author Sterling Hughes <sterling@php.net>
*/
function &glob ($pattern, $dirpath, $pattern_type='php')
{
@@ -52,22 +64,27 @@
if ($match_function ($pattern, $entry) &&
$entry != '.' &&
$entry != '..') {
- $matches[] = &$entry;
+ $matches[] = $entry;
}
}
@closedir ($dh);
return ($matches);
}
-
-
- /*
- * array maptree ( string directory_path )
- * Will return two arrays the first a listing of all the sub directories under
- * the specified directory and the second listing all the files under the
- * specified directory.
+
+ /**
+ * Map the directory tree given by the directory_path parameter.
+ *
+ * @param $directory_path contains the directory path that you
+ * want to map.
+ *
+ * @return a two element array, the first element containing a list
+ * of all the directories, the second element containing a list of all the
+ * files.
+ *
+ * @author Sterling Hughes <sterling@php.net>
*/
- function maptree ($directory)
+ function &maptree ($directory)
{
$this->_dirs = array ($directory);
@@ -78,16 +95,24 @@
array_push ($this->directories, $dir);
}
- return array (&$this->directories, &$this->files);
+ return array ($this->directories, $this->files);
}
-
- /*
- * array search ( string pattern, string directory [, string regex_type] )
- * Will search an entire directory tree for a pattern specified by the 'pattern'
- * argument, in a directory specified by the 'directory' argument, of a pattern
- * type specified by 'regex_type'. If regex_type is left out than PHP type regular
- * expressions will be used. If you want to specify the use of eregi instead of
- * ereg attach a '/i' onto the very end of your regular expression.
+
+ /**
+ * Search the specified directory tree with the specified pattern. Return an
+ * array containing all matching files (no directories included).
+ *
+ * @param $pattern the pattern to match every file with.
+ *
+ * @param $directory the directory tree to search in.
+ *
+ * @param $regex_type the type of regular expression support to use, either
+ * 'php' or 'perl'.
+ *
+ * @return a list of files matching the pattern parameter in the the directory
+ * path specified by the directory parameter
+ *
+ * @author Sterling Hughes <sterling@php.net>
*/
function &search ($pattern, $directory, $type='php') {
list (,$files) = File_Find::maptree ($directory);
@@ -103,18 +128,23 @@
return ($matches);
}
- /*
- * bool isError ($var)
- * Determine whether or not a variable is a PEAR exception
+ /**
+ * Determine whether or not a variable is a PEAR exception
+ *
+ * @param $var the variable to test.
+ *
+ * @return returns true if the variable is a PEAR error, otherwise
+ * it returns false.
*/
function isError (&$var)
{
return PEAR::isError($var);
}
- /*
- * double File_Find_version(void)
- * Returns the current File_Find version.
+ /**
+ * Fetch the current File_Find version
+ *
+ * @return the current File_Find version.
*/
function File_Find_version()
{
@@ -136,15 +166,19 @@
while ($entry = @readdir ($dh))
{
+
if ($entry != '.' &&
$entry != '..') {
+
$entry = "$directory/$entry";
if (is_dir ($entry))
array_push ($this->_dirs, $entry);
else
array_push ($this->files, $entry);
+
}
+
}
@closedir ($dh);