cvs: php4 /pear/DB sybase.php
| From: | Thomas V.V.Cox | Date: | Tue, 07 Aug 2001 11:45:27 +0000 |
| Subject: | cvs: php4 /pear/DB sybase.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-431@lists.php.net to get a copy of this message | ||
cox Tue Aug 7 07:45:27 2001 EDT
Modified files:
/php4/pear/DB sybase.php
Log:
added affectedRows() and error detecting in connect()
Index: php4/pear/DB/sybase.php
diff -u php4/pear/DB/sybase.php:1.19 php4/pear/DB/sybase.php:1.20
--- php4/pear/DB/sybase.php:1.19 Mon Jul 30 16:43:12 2001
+++ php4/pear/DB/sybase.php Tue Aug 7 07:45:23 2001
@@ -16,7 +16,7 @@
// | Authors: Sterling Hughes <sterling@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: sybase.php,v 1.19 2001/07/30 20:43:12 ssb Exp $
+// $Id: sybase.php,v 1.20 2001/08/07 11:45:23 cox Exp $
//
// Database independent query interface definition for PHP's Sybase
// extension.
@@ -54,28 +54,31 @@
function connect($dsninfo, $persistent = false)
{
$this->dsn = $dsninfo;
- $user = $dsninfo['username'];
- $pw = $dsninfo['password'];
-
- $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] :
'localhost';
- $connect_function = $persistent ? 'sybase_pconnect' : 'sybase_connect';
-
- if ($dbhost && $user && $pw) {
- $conn = $connect_function($dbhost, $user, $pw);
- }
- else if ($dbhost && $user) {
- $conn = $connect_function($dbhost, $user);
- }
- else if ($dbhost) {
- $conn = $connect_function($dbhost);
- }
- else {
- $conn = $connect_function();
- }
-
- if ($dsninfo['database'])
- @sybase_select_db($dsninfo['database'], $conn);
-
+ $user = $dsninfo['username'];
+ $pw = $dsninfo['password'];
+
+ $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] :
'localhost';
+ $connect_function = $persistent ? 'sybase_pconnect' : 'sybase_connect';
+
+ if ($dbhost && $user && $pw) {
+ $conn = $connect_function($dbhost, $user, $pw);
+ } elseif ($dbhost && $user) {
+ $conn = $connect_function($dbhost, $user);
+ } elseif ($dbhost) {
+ $conn = $connect_function($dbhost);
+ } else {
+ $conn = $connect_function();
+ }
+
+ if (!$conn) {
+ return $this->raiseError(DB_ERROR_CONNECT_FAILED);
+ }
+
+ if ($dsninfo['database']) {
+ if (!@sybase_select_db($dsninfo['database'], $conn)) {
+ return $this->raiseError(DB_ERROR_NODBSELECTED);
+ }
+ }
$this->connection = $conn;
return DB_OK;
}
@@ -177,6 +180,27 @@
}
// }}}
+ // {{{ affectedRows()
+
+ /**
+ * Gets the number of rows affected by the data manipulation
+ * query. For other queries, this function returns 0.
+ *
+ * @return number of rows affected by the last query
+ */
+
+ function affectedRows()
+ {
+ if (DB::isManip($this->last_query)) {
+ $result = @sybase_affected_rows($this->connection);
+ } else {
+ $result = 0;
+ }
+ return $result;
+ }
+
+ // }}}
+
}
/*