cvs: pear /MDB/MDB Common.php fbsql.php mysql.php pgsql.php /MDB/MDB/Modules/Manager fbsql.php mysql.php pgsql.php

From: Date: Sun, 19 Jan 2003 11:12:45 +0000
Subject: cvs: pear /MDB/MDB Common.php fbsql.php mysql.php pgsql.php /MDB/MDB/Modules/Manager fbsql.php mysql.php pgsql.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8404@lists.php.net to get a copy of this message
lsmith Sun Jan 19 06:12:45 2003 EDT Modified files: /pear/MDB/MDB pgsql.php mysql.php fbsql.php Common.php /pear/MDB/MDB/Modules/Manager pgsql.php mysql.php fbsql.php Log: - changed default value for $rownum in fetchInto() - cs fixes

Index: pear/MDB/MDB/pgsql.php diff -u pear/MDB/MDB/pgsql.php:1.49 pear/MDB/MDB/pgsql.php:1.50 --- pear/MDB/MDB/pgsql.php:1.49 Thu Jan 16 11:08:05 2003 +++ pear/MDB/MDB/pgsql.php Sun Jan 19 06:12:43 2003 @@ -42,9 +42,9 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.49 2003/01/16 16:08:05 lsmith Exp $ +// $Id: pgsql.php,v 1.50 2003/01/19 11:12:43 lsmith Exp $ -require_once 'MDB/Common.php'; +require_once('MDB/Common.php'); /** * MDB PostGreSQL driver @@ -77,19 +77,19 @@ function MDB_pgsql($dsninfo = NULL, $options = NULL) { if(MDB::isError($common_contructor = $this->MDB_common($dsninfo, $options))) { - return $common_contructor; + return($common_contructor); } $this->phptype = 'pgsql'; $this->dbsyntax = 'pgsql'; if (PEAR::isError(PEAR::loadExtension($this->phptype))) { - return PEAR::raiseError(NULL, MDB_ERROR_NOT_FOUND, + return(PEAR::raiseError(NULL, MDB_ERROR_NOT_FOUND, NULL, NULL, 'extension '.$this->phptype.' is not compiled into PHP', - 'MDB_Error', TRUE); + 'MDB_Error', TRUE)); } if (!function_exists('pg_connect')) { - return ('PostgreSQL support is not available in this PHP configuration'); + return('PostgreSQL support is not available in this PHP configuration'); } $this->supported['Sequences'] = 1; $this->supported['Indexes'] = 1; @@ -122,7 +122,7 @@ $err = $this->raiseError(MDB_ERROR, NULL, NULL, 'Setup: could not execute BEGIN'); } if (isset($err) && MDB::isError($err)) { - return ($err); + return($err); } } } @@ -156,11 +156,11 @@ } foreach ($error_regexps as $regexp => $code) { if (preg_match($regexp, $errormsg)) { - return $code; + return($code); } } // Fall back to MDB_ERROR if there was no mapping. - return MDB_ERROR; + return(MDB_ERROR); } // }}} @@ -185,7 +185,7 @@ } else { $err = $errno; } - return $this->raiseError($err, NULL, NULL, NULL, $native); + return($this->raiseError($err, NULL, NULL, NULL, $native)); } // }}} @@ -224,14 +224,14 @@ { $this->debug('AutoCommit: '.($auto_commit ? 'On' : 'Off')); if (((!$this->auto_commit) == (!$auto_commit))) { - return (MDB_OK); + return(MDB_OK); } if ($this->connection) { if (MDB::isError($result = $this->_doQuery($auto_commit ? 'END' : 'BEGIN'))) - return ($result); + return($result); } $this->auto_commit = $auto_commit; - return ($this->_registerTransactionShutdown($auto_commit)); + return($this->_registerTransactionShutdown($auto_commit)); } // }}} @@ -250,9 +250,9 @@ { $this->debug('Commit Transaction'); if ($this->auto_commit) { - return ($this->raiseError(MDB_ERROR, '', '', 'Commit: transaction changes are being auto commited')); + return($this->raiseError(MDB_ERROR, '', '', 'Commit: transaction changes are being auto commited')); } - return ($this->_doQuery('COMMIT') && $this->_doQuery('BEGIN')); + return($this->_doQuery('COMMIT') && $this->_doQuery('BEGIN')); } // }}} @@ -271,9 +271,9 @@ { $this->debug('Rollback Transaction'); if ($this->auto_commit) { - return ($this->raiseError(MDB_ERROR, '', '', 'Rollback: transactions can not be rolled back when changes are auto commited')); + return($this->raiseError(MDB_ERROR, '', '', 'Rollback: transactions can not be rolled back when changes are auto commited')); } - return ($this->_doQuery('ROLLBACK') && $this->_doQuery('BEGIN')); + return($this->_doQuery('ROLLBACK') && $this->_doQuery('BEGIN')); } // }}} @@ -289,7 +289,7 @@ { $function = ($persistent ? 'pg_pconnect' : 'pg_connect'); if (!function_exists($function)) { - return ($this->raiseError(MDB_ERROR_UNSUPPORTED, NULL, NULL, 'doConnect: PostgreSQL support is not available in this PHP configuration')); + return($this->raiseError(MDB_ERROR_UNSUPPORTED, NULL, NULL, 'doConnect: PostgreSQL support is not available in this PHP configuration')); } $port = (isset($this->port) ? $this->port : ''); if ($database_name == '') { @@ -309,14 +309,14 @@ $connect_string .= ' password='.$this->password; } if (($connection = @$function($connect_string)) > 0) { - return ($connection); + return($connection); } if (isset($php_errormsg)) { $error_msg = $php_errormsg; } else { $error_msg = 'Could not connect to PostgreSQL server'; } - return ($this->raiseError(MDB_ERROR_CONNECT_FAILED, '', '', 'doConnect: '.$error_msg)); + return($this->raiseError(MDB_ERROR_CONNECT_FAILED, '', '', 'doConnect: '.$error_msg)); } // }}} @@ -337,7 +337,7 @@ && !strcmp($this->selected_database, $this->database_name) && ($this->opened_persistent == $this->options['persistent'])) { - return (MDB_OK); + return(MDB_OK); } pg_Close($this->connection); $this->affected_rows = -1; @@ -345,7 +345,7 @@ } $connection = $this->_doConnect($this->database_name, $this->options['persistent']); if (MDB::isError($connection)) { - return $connection; + return($connection); } $this->connection = $connection; @@ -353,13 +353,13 @@ pg_Close($this->connection); $this->connection = 0; $this->affected_rows = -1; - return $trans_result; + return($trans_result); } $this->connected_host = $this->host; $this->connected_port = $port; $this->selected_database = $this->database_name; $this->opened_persistent = $this->options['persistent']; - return (MDB_OK); + return(MDB_OK); } // }}} @@ -382,9 +382,9 @@ global $_MDB_databases; $_MDB_databases[$this->database] = ''; - return TRUE; + return(TRUE); } - return FALSE; + return(FALSE); } // }}} @@ -402,9 +402,9 @@ $this->affected_rows = (isset($this->supported['AffectedRows']) ? pg_cmdTuples($result) : -1); } else { $error = pg_ErrorMessage($this->connection); - return $this->pgsqlRaiseError(); + return($this->pgsqlRaiseError()); } - return ($result); + return($result); } // }}} @@ -420,13 +420,13 @@ function _standaloneQuery($query) { if (($connection = $this->_doConnect('template1', 0)) == 0) { - return $this->raiseError(MDB_ERROR_CONNECT_FAILED, NULL, NULL, '_standaloneQuery: Cannot connect to template1'); + return($this->raiseError(MDB_ERROR_CONNECT_FAILED, NULL, NULL, '_standaloneQuery: Cannot connect to template1')); } if (!($success = @pg_Exec($connection, $query))) { $this->raiseError(MDB_ERROR, NULL, NULL, '_standaloneQuery: ' . pg_ErrorMessage($connection)); } pg_Close($connection); - return ($success); + return($success); } // }}} @@ -450,7 +450,7 @@ $this->first_selected_row = $this->selected_row_limit = 0; $connected = $this->connect(); if (MDB::isError($connected)) { - return $connected; + return($connected); } if (!$ismanip && $limit > 0 && @@ -458,34 +458,34 @@ 0, 6) == 'select') { if ($this->auto_commit && MDB::isError($this->_doQuery('BEGIN'))) { - return $this->raiseError(MDB_ERROR); + return($this->raiseError(MDB_ERROR)); } $result = $this->_doQuery('DECLARE select_cursor SCROLL CURSOR FOR '.$query); if (!MDB::isError($result)) { if ($first > 0 && MDB::isError($result = $this->_doQuery("MOVE FORWARD $first FROM select_cursor"))) { $this->freeResult($result); - return $result; + return($result); } if (MDB::isError($result = $this->_doQuery("FETCH FORWARD $limit FROM select_cursor"))) { $this->freeResult($result); - return $result; + return($result); } } else { - return $result; + return($result); } if ($this->auto_commit && MDB::isError($result2 = $this->_doQuery('END'))) { $this->freeResult($result); - return $result2; + return($result2); } } else { $result = $this->_doQuery($query); if (MDB::isError($result)) { - return $result; + return($result); } } if ($ismanip) { $this->affected_rows = @pg_cmdtuples($result); - return MDB_OK; + return(MDB_OK); } elseif (preg_match('/^\s*\(?\s*SELECT\s+/si', $query) && !preg_match('/^\s*\(?\s*SELECT\s+INTO\s/si', $query)) { $this->highest_fetched_row[$result] = -1; if ($types != NULL) { @@ -494,15 +494,15 @@ } if (MDB::isError($err = $this->setResultTypes($result, $types))) { $this->freeResult($result); - return $err; + return($err); } } - return $result; + return($result); } else { $this->affected_rows = 0; - return MDB_OK; + return(MDB_OK); } - return $this->raiseError(MDB_ERROR); + return($this->raiseError(MDB_ERROR)); } // }}} @@ -524,7 +524,7 @@ function getColumnNames($result) { if (!isset($this->highest_fetched_row[$result])) { - return ($this->raiseError(MDB_ERROR, NULL, NULL, 'Get Column Names: specified an nonexistant result set')); + return($this->raiseError(MDB_ERROR, NULL, NULL, 'Get Column Names: specified an nonexistant result set')); } if (!isset($this->columns[$result])) { $this->columns[$result] = array(); @@ -533,7 +533,7 @@ $this->columns[$result][strtolower(pg_fieldname($result, $column))] = $column; } } - return ($this->columns[$result]); + return($this->columns[$result]); } // }}} @@ -550,9 +550,9 @@ function numCols($result) { if (!isset($this->highest_fetched_row[$result])) { - return $this->raiseError(MDB_ERROR, NULL, NULL, 'numCols: specified an nonexistant result set'); + return($this->raiseError(MDB_ERROR, NULL, NULL, 'numCols: specified an nonexistant result set')); } - return (pg_numfields($result)); + return(pg_numfields($result)); } // }}} @@ -568,9 +568,9 @@ function endOfResult($result) { if (!isset($this->highest_fetched_row[$result])) { - return $this->RaiseError(MDB_ERROR, '', '', 'End of result attempted to check the end of an unknown result'); + return($this->RaiseError(MDB_ERROR, '', '', 'End of result attempted to check the end of an unknown result')); } - return ($this->highest_fetched_row[$result] >= $this->numRows($result) - 1); + return($this->highest_fetched_row[$result] >= $this->numRows($result) - 1); } // }}} @@ -590,9 +590,9 @@ $this->highest_fetched_row[$result] = max($this->highest_fetched_row[$result], $row); $res = @pg_result($result, $row, $field); if ($res === FALSE && $res != NULL) { - return $this->pgsqlRaiseError(); + return($this->pgsqlRaiseError()); } - return ($res); + return($res); } // }}} @@ -608,12 +608,12 @@ function _retrieveLob($lob) { if (!isset($this->lobs[$lob])) { - return ($this->raiseError(MDB_ERROR_INVALID, NULL, NULL, 'Retrieve LOB: did not specified a valid lob')); + return($this->raiseError(MDB_ERROR_INVALID, NULL, NULL, 'Retrieve LOB: did not specified a valid lob')); } if (!isset($this->lobs[$lob]['Value'])) { if ($this->auto_commit) { if (!@pg_exec($this->connection, 'BEGIN')) { - return ($this->raiseError(MDB_ERROR, NULL, NULL, 'Retrieve LOB: ' . pg_ErrorMessage($this->connection))); + return($this->raiseError(MDB_ERROR, NULL, NULL, 'Retrieve LOB: ' . pg_ErrorMessage($this->connection))); } $this->lobs[$lob]['InTransaction'] = 1; } @@ -624,10 +624,10 @@ unset($this->lobs[$lob]['InTransaction']); } unset($this->lobs[$lob]['Value']); - return ($this->raiseError(MDB_ERROR, NULL, NULL, 'Retrieve LOB: ' . pg_ErrorMessage($this->connection))); + return($this->raiseError(MDB_ERROR, NULL, NULL, 'Retrieve LOB: ' . pg_ErrorMessage($this->connection))); } } - return (MDB_OK); + return(MDB_OK); } // }}} @@ -645,9 +645,9 @@ { $lobresult = $this->_retrieveLob($lob); if (MDB::isError($lobresult)) { - return ($lobresult); + return($lobresult); } - return (isset($this->lobs[$lob]['EndOfLOB'])); + return(isset($this->lobs[$lob]['EndOfLOB'])); } // }}} @@ -668,7 +668,7 @@ { $lobresult = $this->_retrieveLob($lob); if (MDB::isError($lobresult)) { - return ($lobresult); + return($lobresult); } $data = pg_loread($this->lobs[$lob]['Handle'], $length); if (gettype($data) != 'string') { @@ -677,7 +677,7 @@ if (($length = strlen($data)) == 0) { $this->lobs[$lob]['EndOfLOB'] = 1; } - return ($length); + return($length); } // }}} @@ -718,7 +718,7 @@ */ function fetchClob($result, $row, $field) { - return ($this->fetchLob($result, $row, $field)); + return($this->fetchLob($result, $row, $field)); } // }}} @@ -735,7 +735,7 @@ */ function fetchBlob($result, $row, $field) { - return ($this->fetchLob($result, $row, $field)); + return($this->fetchLob($result, $row, $field)); } // }}} @@ -753,19 +753,19 @@ { switch ($type) { case MDB_TYPE_BOOLEAN: - return (strcmp($value, 'Y') ? 0 : 1); + return(strcmp($value, 'Y') ? 0 : 1); case MDB_TYPE_DECIMAL: - return (sprintf('%.'.$this->decimal_places.'f',doubleval($value)/$this->decimal_factor)); + return(sprintf('%.'.$this->decimal_places.'f',doubleval($value)/$this->decimal_factor)); case MDB_TYPE_FLOAT: return doubleval($value); case MDB_TYPE_DATE: - return ($value); + return($value); case MDB_TYPE_TIME: - return ($value); + return($value); case MDB_TYPE_TIMESTAMP: return substr($value, 0, strlen('YYYY-MM-DD HH:MM:SS')); default: - return ($this->_baseConvertResult($value, $type)); + return($this->_baseConvertResult($value, $type)); } } @@ -785,7 +785,7 @@ function resultIsNull($result, $row, $field) { $this->highest_fetched_row[$result] = max($this->highest_fetched_row[$result], $row); - return (@pg_FieldIsNull($result, $row, $field)); + return(@pg_FieldIsNull($result, $row, $field)); } // }}} @@ -800,7 +800,7 @@ */ function numRows($result) { - return (pg_numrows($result)); + return(pg_numrows($result)); } // }}} @@ -824,7 +824,7 @@ if(isset($this->result_types[$result])) { unset($this->result_types[$result]); } - return (pg_freeresult($result)); + return(pg_freeresult($result)); } // }}} @@ -856,7 +856,7 @@ */ function getTextDeclaration($name, $field) { - return ((isset($field['length']) ? "$name VARCHAR (" . $field['length'] . ')' : "$name TEXT") . (isset($field['default']) ? " DEFAULT '" . $field['default'] . "'" : '') . (isset($field['notnull']) ? ' NOT NULL' : '')); + return((isset($field['length']) ? "$name VARCHAR (" . $field['length'] . ')' : "$name TEXT") . (isset($field['default']) ? " DEFAULT '" . $field['default'] . "'" : '') . (isset($field['notnull']) ? ' NOT NULL' : '')); } // }}} @@ -885,7 +885,7 @@ */ function getClobDeclaration($name, $field) { - return ("$name OID".(isset($field['notnull']) ? ' NOT NULL' : '')); + return("$name OID".(isset($field['notnull']) ? ' NOT NULL' : '')); } // }}} @@ -914,7 +914,7 @@ */ function getBlobDeclaration($name, $field) { - return ("$name OID".(isset($field['notnull']) ? ' NOT NULL' : '')); + return("$name OID".(isset($field['notnull']) ? ' NOT NULL' : '')); } // }}} @@ -941,7 +941,7 @@ */ function getDateDeclaration($name, $field) { - return ($name.' DATE'.(isset($field['default']) ? ' DEFAULT \''.$field['default'] . "'" : '').(isset($field['notnull']) ? ' NOT NULL' : '')); + return($name.' DATE'.(isset($field['default']) ? ' DEFAULT \''.$field['default'] . "'" : '').(isset($field['notnull']) ? ' NOT NULL' : '')); } // }}} @@ -968,7 +968,7 @@ */ function getTimeDeclaration($name, $field) { - return ($name.' TIME'.(isset($field['default']) ? ' DEFAULT \''.$field['default'].'\'' : '').(isset($field['notnull']) ? ' NOT NULL' : '')); + return($name.' TIME'.(isset($field['default']) ? ' DEFAULT \''.$field['default'].'\'' : '').(isset($field['notnull']) ? ' NOT NULL' : '')); } // }}} @@ -995,7 +995,7 @@ */ function getFloatDeclaration($name, $field) { - return ("$name FLOAT8 ".(isset($field['default']) ? ' DEFAULT '.$this->getFloatValue($field['default']) : '').(isset($field['notnull']) ? ' NOT NULL' : '')); + return("$name FLOAT8 ".(isset($field['default']) ? ' DEFAULT '.$this->getFloatValue($field['default']) : '').(isset($field['notnull']) ? ' NOT NULL' : '')); } // }}} @@ -1022,7 +1022,7 @@ */ function getDecimalDeclaration($name, $field) { - return ("$name INT8 ".(isset($field['default']) ? ' DEFAULT '.$this->getDecimalValue($field['default']) : '').(isset($field['notnull']) ? ' NOT NULL' : '')); + return("$name INT8 ".(isset($field['default']) ? ' DEFAULT '.$this->getDecimalValue($field['default']) : '').(isset($field['notnull']) ? ' NOT NULL' : '')); } // }}} @@ -1043,10 +1043,10 @@ { $connect = $this->connect(); if (MDB::isError($connect)) { - return $connect; + return($connect); } if ($this->auto_commit && !@pg_Exec($this->connection, 'BEGIN')) { - return $this->raiseError(MDB_ERROR, NULL, NULL, '_getLobValue: error starting transaction'); + return($this->raiseError(MDB_ERROR, NULL, NULL, '_getLobValue: error starting transaction')); } if (($lo = pg_locreate($this->connection))) { if (($handle = pg_loopen($this->connection, $lo, 'w'))) { @@ -1076,9 +1076,9 @@ @pg_Exec($this->connection, 'END'); } if (MDB::isError($result)) { - return $result; + return($result); } - return ($value); + return($value); } // }}} @@ -1097,7 +1097,7 @@ */ function getClobValue($prepared_query, $parameter, $clob) { - return ($this->_getLobValue($prepared_query, $parameter, $clob)); + return($this->_getLobValue($prepared_query, $parameter, $clob)); } // }}} @@ -1114,7 +1114,7 @@ function freeClobValue($prepared_query, $clob) { unset($this->lobs[$clob]); - return MDB_OK; + return(MDB_OK); } // }}} @@ -1133,7 +1133,7 @@ */ function getBlobValue($prepared_query, $parameter, $blob) { - return ($this->_getLobValue($prepared_query, $parameter, $blob)); + return($this->_getLobValue($prepared_query, $parameter, $blob)); } // }}} @@ -1150,7 +1150,7 @@ function freeBlobValue($prepared_query, $blob) { unset($this->lobs[$blob]); - return MDB_OK; + return(MDB_OK); } // }}} @@ -1167,7 +1167,7 @@ */ function getFloatValue($value) { - return (!strcmp($value, 'NULL') ? 'NULL' : $value); + return(!strcmp($value, 'NULL') ? 'NULL' : $value); } // }}} @@ -1184,7 +1184,7 @@ */ function getDecimalValue($value) { - return (!strcmp($value, 'NULL') ? 'NULL' : strval(round($value*$this->decimal_factor))); + return(!strcmp($value, 'NULL') ? 'NULL' : strval(round($value*$this->decimal_factor))); } // }}} @@ -1212,7 +1212,7 @@ $repeat = 1; $result = $this->createSequence($seq_name); if (MDB::isError($result)) { - return $this->raiseError($result); + return($this->raiseError($result)); } } else { $repeat = 0; @@ -1220,11 +1220,11 @@ } while ($repeat); if (MDB::isError($result)) { - return $this->raiseError($result); + return($this->raiseError($result)); } $arr = $this->fetchInto($result, MDB_FETCHMODE_ORDERED); $this->freeResult($result); - return ($arr[0]); + return($arr[0]); } // }}} @@ -1241,12 +1241,12 @@ { $seqname = $this->getSequenceName($seq_name); if (MDB::isError($result = $this->queryOne("SELECT last_value FROM $seqname"))) { - return $this->raiseError(MDB_ERROR, NULL, NULL, 'currId: Unable to select from ' . $seqname) ; + return($this->raiseError(MDB_ERROR, NULL, NULL, 'currId: Unable to select from ' . $seqname) ); } if (!is_int($result)) { - return ($this->raiseError(MDB_ERROR, NULL, NULL, 'currId: could not find value in sequence table')); + return($this->raiseError(MDB_ERROR, NULL, NULL, 'currId: could not find value in sequence table')); } - return ($result); + return($result); } @@ -1262,16 +1262,16 @@ * @return int data array on success, a MDB error on failure * @access public */ - function fetchInto($result, $fetchmode = MDB_FETCHMODE_DEFAULT, $rownum = NULL) + function fetchInto($result, $fetchmode = MDB_FETCHMODE_DEFAULT, $rownum = 0) { - if ($rownum == NULL) { + if ($rownum == 0) { ++$this->highest_fetched_row[$result]; $rownum = $this->highest_fetched_row[$result]; } else { $this->highest_fetched_row[$result] = max($this->highest_fetched_row[$result], $rownum); } if ($rownum + 1 > $this->numRows($result)) { - return NULL; + return(NULL); } if ($fetchmode == MDB_FETCHMODE_DEFAULT) { $fetchmode = $this->fetchmode; @@ -1287,14 +1287,14 @@ if ($this->options['autofree']) { $this->freeResult($result); } - return NULL; + return(NULL); } - return $this->pgsqlRaiseError($errno); + return($this->pgsqlRaiseError($errno)); } if (isset($this->result_types[$result])) { $array = $this->convertResultRow($result, $array); } - return ($array); + return($array); } // }}} @@ -1309,7 +1309,7 @@ */ function nextResult($result) { - return FALSE; + return(FALSE); } // }}} @@ -1371,12 +1371,12 @@ if (is_string($result)) { $id = pg_exec($this->connection, "SELECT * FROM $result"); if (empty($id)) { - return $this->pgsqlRaiseError(); + return($this->pgsqlRaiseError()); } } else { // else we want information about a resultset $id = $result; if (empty($id)) { - return $this->pgsqlRaiseError(); + return($this->pgsqlRaiseError()); } } @@ -1413,7 +1413,7 @@ if (is_string($result) && is_resource($id)) { @pg_freeresult($id); } - return $res; + return($res); } // }}} Index: pear/MDB/MDB/mysql.php diff -u pear/MDB/MDB/mysql.php:1.64 pear/MDB/MDB/mysql.php:1.65 --- pear/MDB/MDB/mysql.php:1.64 Thu Jan 16 11:08:05 2003 +++ pear/MDB/MDB/mysql.php Sun Jan 19 06:12:43 2003 @@ -42,10 +42,10 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.64 2003/01/16 16:08:05 lsmith Exp $ +// $Id: mysql.php,v 1.65 2003/01/19 11:12:43 lsmith Exp $ // -require_once 'MDB/Common.php'; +require_once('MDB/Common.php'); /** * MDB MySQL driver @@ -85,16 +85,16 @@ function MDB_mysql($dsninfo = NULL, $options = NULL) { if(MDB::isError($common_contructor = $this->MDB_common($dsninfo, $options))) { - return $common_contructor; + return($common_contructor); } $this->phptype = 'mysql'; $this->dbsyntax = 'mysql'; if (PEAR::isError(PEAR::loadExtension($this->phptype))) { - return PEAR::raiseError(NULL, MDB_ERROR_NOT_FOUND, + return(PEAR::raiseError(NULL, MDB_ERROR_NOT_FOUND, NULL, NULL, 'extension '.$this->phptype.' is not compiled into PHP', - 'MDB_Error', TRUE); + 'MDB_Error', TRUE)); } $this->supported['Sequences'] = 1; @@ -194,7 +194,7 @@ if ($errno == NULL) { $errno = $this->errorCode(mysql_errno($this->connection)); } - return $this->raiseError($errno, NULL, NULL, NULL, @mysql_error($this->connection)); + return($this->raiseError($errno, NULL, NULL, NULL, @mysql_error($this->connection))); } // }}} @@ -220,31 +220,31 @@ { $this->debug("AutoCommit: ".($auto_commit ? "On" : "Off")); if (!isset($this->supported['Transactions'])) { - return $this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', - 'Auto-commit transactions: transactions are not in use'); + return($this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', + 'Auto-commit transactions: transactions are not in use')); } if (((!$this->auto_commit) == (!$auto_commit))) { - return (MDB_OK); + return(MDB_OK); } if ($this->connection) { if ($auto_commit) { $result = $this->query('COMMIT'); if (MDB::isError($result)) { - return $result; + return($result); } $result = $this->query('SET AUTOCOMMIT = 1'); if (MDB::isError($result)) { - return $result; + return($result); } } else { $result = $this->query('SET AUTOCOMMIT = 0'); if (MDB::isError($result)) { - return $result; + return($result); } } } $this->auto_commit = $auto_commit; - return ($this->_registerTransactionShutdown($auto_commit)); + return($this->_registerTransactionShutdown($auto_commit)); } // }}} @@ -264,14 +264,14 @@ { $this->debug("Commit Transaction"); if (!isset($this->supported['Transactions'])) { - return $this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', - 'Commit transactions: transactions are not in use'); + return($this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', + 'Commit transactions: transactions are not in use')); } if ($this->auto_commit) { - return $this->raiseError(MDB_ERROR, '', '', - 'Commit transactions: transaction changes are being auto commited'); + return($this->raiseError(MDB_ERROR, '', '', + 'Commit transactions: transaction changes are being auto commited')); } - return ($this->query('COMMIT')); + return($this->query('COMMIT')); } // }}} @@ -291,14 +291,14 @@ { $this->debug("Rollback Transaction"); if (!isset($this->supported['Transactions'])) { - return $this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', - 'Rollback transactions: transactions are not in use'); + return($this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', + 'Rollback transactions: transactions are not in use')); } if ($this->auto_commit) { - return $this->raiseError(MDB_ERROR, '', '', - 'Rollback transactions: transactions can not be rolled back when changes are auto commited'); + return($this->raiseError(MDB_ERROR, '', '', + 'Rollback transactions: transactions can not be rolled back when changes are auto commited')); } - return ($this->query('ROLLBACK')); + return($this->query('ROLLBACK')); } // }}} @@ -319,7 +319,7 @@ && !strcmp($this->connected_port, $port) && $this->opened_persistent == $this->options['persistent']) { - return (MDB_OK); + return(MDB_OK); } mysql_close($this->connection); $this->connection = 0; @@ -328,7 +328,7 @@ $this->fixed_float = 30; $function = ($this->options['persistent'] ? 'mysql_pconnect' : 'mysql_connect'); if (!function_exists($function)) { - return ($this->raiseError(MDB_ERROR_UNSUPPORTED)); + return($this->raiseError(MDB_ERROR_UNSUPPORTED)); } @ini_set('track_errors', TRUE); @@ -337,7 +337,7 @@ $this->user, $this->password); @ini_restore('track_errors'); if ($this->connection <= 0) { - return ($this->raiseError(MDB_ERROR_CONNECT_FAILED, '', '', + return($this->raiseError(MDB_ERROR_CONNECT_FAILED, '', '', $php_errormsg)); } @@ -345,7 +345,7 @@ $this->fixed_float = $this->options['fixedfloat']; } else { if (($result = mysql_query('SELECT VERSION()', $this->connection))) { - $version = explode('.',mysql_result($result,0,0)); + $version = explode('.', mysql_result($result,0,0)); $major = intval($version[0]); $minor = intval($version[1]); $revision = intval($version[2]); @@ -362,7 +362,7 @@ mysql_close($this->connection); $this->connection = 0; $this->affected_rows = -1; - return ($this->raiseError()); + return($this->raiseError()); } $this->_registerTransactionShutdown(0); } @@ -371,7 +371,7 @@ $this->connected_password = $this->password; $this->connected_port = $port; $this->opened_persistent = $this->options['persistent']; - return (MDB_OK); + return(MDB_OK); } // }}} @@ -393,13 +393,13 @@ $this->affected_rows = -1; if (isset($result) && MDB::isError($result)) { - return $result; + return($result); } global $_MDB_databases; $_MDB_databases[$this->database] = ''; - return TRUE; + return(TRUE); } - return FALSE; + return(FALSE); } // }}} @@ -427,7 +427,7 @@ $result = $this->connect(); if (MDB::isError($result)) { - return $result; + return($result); } if($limit > 0) { if ($ismanip) { @@ -436,17 +436,15 @@ $query .= " LIMIT $first,$limit"; } } - - if ($this->database_name != '') { + if ($this->database_name) { if(!mysql_select_db($this->database_name, $this->connection)) { - return $this->mysqlRaiseError(); + return($this->mysqlRaiseError()); } } - if ($result = mysql_query($query, $this->connection)) { if ($ismanip) { $this->affected_rows = mysql_affected_rows($this->connection); - return MDB_OK; + return(MDB_OK); } else { $this->highest_fetched_row[$result] = -1; if ($types != NULL) { @@ -455,13 +453,13 @@ } if (MDB::isError($err = $this->setResultTypes($result, $types))) { $this->freeResult($result); - return $err; + return($err); } } - return $result; + return($result); } } - return $this->mysqlRaiseError(); + return($this->mysqlRaiseError()); } // }}} @@ -486,7 +484,7 @@ } $col = $this->queryCol($query); if (MDB::isError($col)) { - return $col; + return($col); } if(!is_array($col) || count($col) == 0) { return 'NULL'; @@ -583,8 +581,8 @@ $value = 'NULL'; } else { if (!isset($fields[$name]['Value'])) { - return $this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', - 'no value for field "'.$name.'" specified'); + return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', + 'no value for field "'.$name.'" specified')); } if(isset($fields[$name]['Type'])) { switch ($fields[$name]['Type']) { @@ -613,8 +611,8 @@ $value = $this->getTimestampValue($fields[$name]['Value']); break; default: - return $this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', - 'no supported type for field "' . $name . '" specified'); + return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', + 'no supported type for field "' . $name . '" specified')); } } else { $value = $fields[$name]['Value']; @@ -623,17 +621,17 @@ $values .= $value; if (isset($fields[$name]['Key']) && $fields[$name]['Key']) { if ($value == 'NULL') { - return $this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', - 'key values may not be NULL'); + return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', + 'key values may not be NULL')); } $keys++; } } if ($keys == 0) { - return $this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', - 'not specified which fields are keys'); + return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', + 'not specified which fields are keys')); } - return ($this->query("REPLACE INTO $table ($query) VALUES ($values)")); + return($this->query("REPLACE INTO $table ($query) VALUES ($values)")); } // }}} @@ -659,8 +657,8 @@ { $result_value = intval($result); if (!isset($this->highest_fetched_row[$result_value])) { - return $this->raiseError(MDB_ERROR_INVALID, '', '', - 'Get column names: it was specified an inexisting result set'); + return($this->raiseError(MDB_ERROR_INVALID, '', '', + 'Get column names: it was specified an inexisting result set')); } if (!isset($this->columns[$result_value])) { $this->columns[$result_value] = array(); @@ -669,7 +667,7 @@ $this->columns[$result_value][strtolower(mysql_field_name($result, $column))] = $column; } } - return ($this->columns[$result_value]); + return($this->columns[$result_value]); } // }}} @@ -686,10 +684,10 @@ function numCols($result) { if (!isset($this->highest_fetched_row[intval($result)])) { - return $this->raiseError(MDB_ERROR_INVALID, '', '', - 'numCols: it was specified an inexisting result set'); + return($this->raiseError(MDB_ERROR_INVALID, '', '', + 'numCols: it was specified an inexisting result set')); } - return (mysql_num_fields($result)); + return(mysql_num_fields($result)); } // }}} @@ -705,10 +703,10 @@ function endOfResult($result) { if (!isset($this->highest_fetched_row[$result])) { - return $this->raiseError(MDB_ERROR, '', '', - 'End of result: attempted to check the end of an unknown result'); + return($this->raiseError(MDB_ERROR, '', '', + 'End of result: attempted to check the end of an unknown result')); } - return ($this->highest_fetched_row[$result] >= $this->numRows($result)-1); + return($this->highest_fetched_row[$result] >= $this->numRows($result)-1); } // }}} @@ -728,9 +726,9 @@ $this->highest_fetched_row[$result] = max($this->highest_fetched_row[$result], $row); $res = @mysql_result($result, $row, $field); if ($res === FALSE && $res != NULL) { - return $this->mysqlRaiseError($errno); + return($this->mysqlRaiseError($errno)); } - return ($res); + return($res); } // }}} @@ -748,7 +746,7 @@ */ function fetchClob($result, $row, $field) { - return ($this->fetchLob($result, $row, $field)); + return($this->fetchLob($result, $row, $field)); } // }}} @@ -765,7 +763,7 @@ */ function fetchBlob($result, $row, $field) { - return ($this->fetchLob($result, $row, $field)); + return($this->fetchLob($result, $row, $field)); } // }}} @@ -783,19 +781,19 @@ { switch($type) { case MDB_TYPE_BOOLEAN: - return (strcmp($value, 'Y') ? 0 : 1); + return(strcmp($value, 'Y') ? 0 : 1); case MDB_TYPE_DECIMAL: - return (sprintf('%.'.$this->decimal_places.'f', doubleval($value)/$this->decimal_factor)); + return(sprintf('%.'.$this->decimal_places.'f', doubleval($value)/$this->decimal_factor)); case MDB_TYPE_FLOAT: - return (doubleval($value)); + return(doubleval($value)); case MDB_TYPE_DATE: - return ($value); + return($value); case MDB_TYPE_TIME: - return ($value); + return($value); case MDB_TYPE_TIMESTAMP: - return ($value); + return($value); default: - return ($this->_baseConvertResult($value, $type)); + return($this->_baseConvertResult($value, $type)); } } @@ -811,7 +809,7 @@ */ function numRows($result) { - return (mysql_num_rows($result)); + return(mysql_num_rows($result)); } // }}} @@ -835,7 +833,7 @@ if(isset($this->result_types[$result])) { unset($this->result_types[$result]); } - return (mysql_free_result($result)); + return(mysql_free_result($result)); } // }}} @@ -869,7 +867,7 @@ */ function getIntegerDeclaration($name, $field) { - return ("$name INT". + return("$name INT". (isset($field['unsigned']) ? ' UNSIGNED' : ''). (isset($field['default']) ? ' DEFAULT '.$field['default'] : ''). (isset($field['notnull']) ? ' NOT NULL' : '') @@ -922,7 +920,7 @@ } else { $type = 'LONGTEXT'; } - return ("$name $type". + return("$name $type". (isset($field['notnull']) ? ' NOT NULL' : '')); } @@ -973,7 +971,7 @@ else { $type = 'LONGBLOB'; } - return ("$name $type". + return("$name $type". (isset($field['notnull']) ? ' NOT NULL' : '')); } @@ -1002,7 +1000,7 @@ */ function getDateDeclaration($name, $field) { - return ("$name DATE". + return("$name DATE". (isset($field['default']) ? " DEFAULT '".$field['default']."'" : ''). (isset($field['notnull']) ? ' NOT NULL' : '') ); @@ -1034,7 +1032,7 @@ */ function getTimestampDeclaration($name, $field) { - return ("$name DATETIME". + return("$name DATETIME". (isset($field['default']) ? " DEFAULT '".$field['default']."'" : ''). (isset($field['notnull']) ? ' NOT NULL' : '') ); @@ -1065,7 +1063,7 @@ */ function getTimeDeclaration($name, $field) { - return ("$name TIME". + return("$name TIME". (isset($field['default']) ? " DEFAULT '".$field['default']."'" : ''). (isset($field['notnull']) ? ' NOT NULL' : '') ); @@ -1105,7 +1103,7 @@ $this->connect(); } } - return ("$name DOUBLE". + return("$name DOUBLE". ($this->fixed_float ? '('.($this->fixed_float + 2).','.$this->fixed_float.')' : ''). (isset($field['default']) ? @@ -1140,7 +1138,7 @@ */ function getDecimalDeclaration($name, $field) { - return ("$name BIGINT". + return("$name BIGINT". (isset($field['default']) ? ' DEFAULT '.$this->getDecimalValue($field['default']) : ''). (isset($field['notnull']) ? ' NOT NULL' : '') @@ -1166,12 +1164,12 @@ $value = "'"; while(!$this->endOfLob($clob)) { if (MDB::isError($result = $this->readLob($clob, $data, $this->options['lob_buffer_length']))) { - return $result; + return($result); } $value .= $this->_quote($data); } $value .= "'"; - return ($value); + return($value); } // }}} @@ -1188,7 +1186,7 @@ function freeClobValue($prepared_query, $clob) { unset($this->lobs[$clob]); - return (MDB_OK); + return(MDB_OK); } // }}} @@ -1210,12 +1208,12 @@ $value = "'"; while(!$this->endOfLob($blob)) { if (MDB::isError($result = $this->readLob($blob, $data, $this->options['lob_buffer_length']))) { - return $result; + return($result); } $value .= addslashes($data); } $value .= "'"; - return ($value); + return($value); } // }}} @@ -1232,7 +1230,7 @@ function freeBlobValue($prepared_query, $blob) { unset($this->lobs[$blob]); - return (MDB_OK); + return(MDB_OK); } // }}} @@ -1249,7 +1247,7 @@ */ function getFloatValue($value) { - return (!strcmp($value, 'NULL') ? 'NULL' : "$value"); + return(!strcmp($value, 'NULL') ? 'NULL' : "$value"); } // }}} @@ -1266,7 +1264,7 @@ */ function getDecimalValue($value) { - return (!strcmp($value, 'NULL') ? 'NULL' : strval(round(doubleval($value)*$this->decimal_factor))); + return(!strcmp($value, 'NULL') ? 'NULL' : strval(round(doubleval($value)*$this->decimal_factor))); } // }}} @@ -1295,11 +1293,11 @@ // we know the first id = 1 so initialize the // sequence at 2 if (MDB::isError($result)) { - return $this->raiseError(MDB_ERROR, '', '', - 'Next ID: on demand sequence could not be created'); + return($this->raiseError(MDB_ERROR, '', '', + 'Next ID: on demand sequence could not be created')); } else { // First ID of a newly created sequence is 1 - return 1; + return(1); } } $value = intval(mysql_insert_id()); @@ -1307,7 +1305,7 @@ if (MDB::isError($res)) { $this->warnings[] = 'Next ID: could not delete previous sequence table values'; } - return ($value); + return($value); } @@ -1326,10 +1324,10 @@ $sequence_name = $this->getSequenceName($seq_name); $result = $this->query("SELECT MAX(sequence) FROM $sequence_name", 'integer'); if (MDB::isError($result)) { - return $result; + return($result); } - return ($this->fetchOne($result)); + return($this->fetchOne($result)); } // }}} @@ -1344,13 +1342,13 @@ * @return int data array on success, a MDB error on failure * @access public */ - function fetchInto($result, $fetchmode = MDB_FETCHMODE_DEFAULT, $rownum = NULL) + function fetchInto($result, $fetchmode = MDB_FETCHMODE_DEFAULT, $rownum = 0) { - if ($rownum == NULL) { + if ($rownum == 0) { ++$this->highest_fetched_row[$result]; } else { if (!@mysql_data_seek($result, $rownum)) { - return NULL; + return(NULL); } $this->highest_fetched_row[$result] = max($this->highest_fetched_row[$result], $rownum); } @@ -1368,14 +1366,14 @@ if($this->options['autofree']) { $this->freeResult($result); } - return NULL; + return(NULL); } - return $this->mysqlRaiseError($errno); + return($this->mysqlRaiseError($errno)); } if (isset($this->result_types[$result])) { $array = $this->convertResultRow($result, $array); } - return ($array); + return($array); } // }}} @@ -1391,7 +1389,7 @@ */ function nextResult($result) { - return FALSE; + return(FALSE); } // }}} @@ -1453,12 +1451,12 @@ $id = @mysql_list_fields($this->database_name, $result, $this->connection); if (empty($id)) { - return $this->mysqlRaiseError(); + return($this->mysqlRaiseError()); } } else { // else we want information about a resultset $id = $result; if (empty($id)) { - return $this->mysqlRaiseError(); + return($this->mysqlRaiseError()); } } @@ -1495,7 +1493,7 @@ if (is_string($result)) { @mysql_free_result($id); } - return $res; + return($res); } } Index: pear/MDB/MDB/fbsql.php diff -u pear/MDB/MDB/fbsql.php:1.4 pear/MDB/MDB/fbsql.php:1.5 --- pear/MDB/MDB/fbsql.php:1.4 Sat Jan 18 10:10:43 2003 +++ pear/MDB/MDB/fbsql.php Sun Jan 19 06:12:43 2003 @@ -42,10 +42,10 @@ // | Author: Lukas Smith <smith@dybnet.de> | // +----------------------------------------------------------------------+ // -// $Id: fbsql.php,v 1.4 2003/01/18 15:10:43 lsmith Exp $ +// $Id: fbsql.php,v 1.5 2003/01/19 11:12:43 lsmith Exp $ // -require_once 'MDB/Common.php'; +require_once('MDB/Common.php'); /** * MDB FrontBase driver @@ -86,16 +86,16 @@ function MDB_fbsql($dsninfo = NULL, $options = NULL) { if(MDB::isError($common_contructor = $this->MDB_common($dsninfo, $options))) { - return $common_contructor; + return($common_contructor); } $this->phptype = 'fbsql'; $this->dbsyntax = 'fbsql'; if (PEAR::isError(PEAR::loadExtension($this->phptype))) { - return PEAR::raiseError(NULL, MDB_ERROR_NOT_FOUND, + return(PEAR::raiseError(NULL, MDB_ERROR_NOT_FOUND, NULL, NULL, 'extension '.$this->phptype.' is not compiled into PHP', - 'MDB_Error', TRUE); + 'MDB_Error', TRUE)); } $this->supported['Sequences'] = 1; @@ -195,7 +195,7 @@ if ($errno == NULL) { $errno = $this->errorCode(fbsql_errno($this->connection)); } - return $this->raiseError($errno, NULL, NULL, NULL, @fbsql_error($this->connection)); + return($this->raiseError($errno, NULL, NULL, NULL, @fbsql_error($this->connection))); } // }}} @@ -221,31 +221,31 @@ { $this->debug('AutoCommit: '.($auto_commit ? 'On' : 'Off')); if (!isset($this->supported['Transactions'])) { - return $this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', - 'Auto-commit transactions: transactions are not in use'); + return($this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', + 'Auto-commit transactions: transactions are not in use')); } if (((!$this->auto_commit) == (!$auto_commit))) { - return (MDB_OK); + return(MDB_OK); } if ($this->connection) { if ($auto_commit) { $result = $this->query('COMMIT'); if (MDB::isError($result)) { - return $result; + return($result); } $result = $this->query('SET COMMIT TRUE'); if (MDB::isError($result)) { - return $result; + return($result); } } else { $result = $this->query('SET COMMIT FALSE'); if (MDB::isError($result)) { - return $result; + return($result); } } } $this->auto_commit = $auto_commit; - return ($this->_registerTransactionShutdown($auto_commit)); + return($this->_registerTransactionShutdown($auto_commit)); } // }}} @@ -265,14 +265,14 @@ { $this->debug('Commit Transaction'); if (!isset($this->supported['Transactions'])) { - return $this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', - 'Commit transactions: transactions are not in use'); + return($this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', + 'Commit transactions: transactions are not in use')); } if ($this->auto_commit) { - return $this->raiseError(MDB_ERROR, '', '', - 'Commit transactions: transaction changes are being auto commited'); + return($this->raiseError(MDB_ERROR, '', '', + 'Commit transactions: transaction changes are being auto commited')); } - return ($this->query('COMMIT')); + return($this->query('COMMIT')); } // }}} @@ -292,14 +292,14 @@ { $this->debug('Rollback Transaction'); if (!isset($this->supported['Transactions'])) { - return $this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', - 'Rollback transactions: transactions are not in use'); + return($this->raiseError(MDB_ERROR_UNSUPPORTED, '', '', + 'Rollback transactions: transactions are not in use')); } if ($this->auto_commit) { - return $this->raiseError(MDB_ERROR, '', '', - 'Rollback transactions: transactions can not be rolled back when changes are auto commited'); + return($this->raiseError(MDB_ERROR, '', '', + 'Rollback transactions: transactions can not be rolled back when changes are auto commited')); } - return ($this->query('ROLLBACK')); + return($this->query('ROLLBACK')); } // }}} @@ -320,7 +320,7 @@ && !strcmp($this->connected_port, $port) && $this->opened_persistent == $this->options['persistent']) { - return (MDB_OK); + return(MDB_OK); } fbsql_close($this->connection); $this->connection = 0; @@ -329,7 +329,7 @@ $this->fixed_float = 30; $function = ($this->options['persistent'] ? 'fbsql_pconnect' : 'fbsql_connect'); if (!function_exists($function)) { - return ($this->raiseError(MDB_ERROR_UNSUPPORTED)); + return($this->raiseError(MDB_ERROR_UNSUPPORTED)); } @ini_set('track_errors', TRUE); @@ -338,7 +338,7 @@ $this->user, $this->password); @ini_restore('track_errors'); if ($this->connection <= 0) { - return ($this->raiseError(MDB_ERROR_CONNECT_FAILED, '', '', + return($this->raiseError(MDB_ERROR_CONNECT_FAILED, '', '', $php_errormsg)); } @@ -363,7 +363,7 @@ fbsql_close($this->connection); $this->connection = 0; $this->affected_rows = -1; - return ($this->raiseError()); + return($this->raiseError()); } $this->_registerTransactionShutdown(0); } @@ -372,7 +372,7 @@ $this->connected_password = $this->password; $this->connected_port = $port; $this->opened_persistent = $this->options['persistent']; - return (MDB_OK); + return(MDB_OK); } // }}} @@ -394,13 +394,13 @@ $this->affected_rows = -1; if (isset($result) && MDB::isError($result)) { - return $result; + return($result); } global $_MDB_databases; $_MDB_databases[$this->database] = ''; - return TRUE; + return(TRUE); } - return FALSE; + return(FALSE); } // }}} @@ -428,7 +428,7 @@ $result = $this->connect(); if (MDB::isError($result)) { - return $result; + return($result); } if($limit > 0) { if (!$ismanip) { @@ -438,7 +438,7 @@ if ($this->database_name != '') { if(!fbsql_select_db($this->database_name, $this->connection)) { - return $this->fbsqlRaiseError(); + return($this->fbsqlRaiseError()); } } @@ -447,7 +447,7 @@ if ($result = fbsql_query($query, $this->connection)) { if ($ismanip) { $this->affected_rows = fbsql_affected_rows($this->connection); - return MDB_OK; + return(MDB_OK); } else { $this->highest_fetched_row[$result] = -1; if ($types != NULL) { @@ -456,13 +456,13 @@ } if (MDB::isError($err = $this->setResultTypes($result, $types))) { $this->freeResult($result); - return $err; + return($err); } } - return $result; + return($result); } } - return $this->fbsqlRaiseError(); + return($this->fbsqlRaiseError()); } // }}} @@ -487,7 +487,7 @@ } $col = $this->queryCol($query); if (MDB::isError($col)) { - return $col; + return($col); } if(!is_array($col) || count($col) == 0) { return 'NULL'; @@ -583,8 +583,8 @@ $value = 'NULL'; } else { if (!isset($fields[$name]['Value'])) { - return $this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', - 'no value for field "'.$name.'" specified'); + return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', + 'no value for field "'.$name.'" specified')); } switch(isset($fields[$name]['Type']) ? $fields[$name]['Type'] : 'text') { case 'text': @@ -612,24 +612,24 @@ $value = $this->getTimestampValue($fields[$name]['Value']); break; default: - return $this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', - 'no supported type for field "'.$name.'" specified'); + return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', + 'no supported type for field "'.$name.'" specified')); } } $values .= $value; if (isset($fields[$name]['Key']) && $fields[$name]['Key']) { if ($value == 'NULL') { - return $this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', - 'key values may not be NULL'); + return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', + 'key values may not be NULL')); } $keys++; } } if ($keys == 0) { - return $this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', - 'not specified which fields are keys'); + return($this->raiseError(MDB_ERROR_CANNOT_REPLACE, '', '', + 'not specified which fields are keys')); } - return ($this->query("REPLACE INTO $table ($query) VALUES ($values)")); + return($this->query("REPLACE INTO $table ($query) VALUES ($values)")); } // }}} @@ -655,8 +655,8 @@ { $result_value = intval($result); if (!isset($this->highest_fetched_row[$result_value])) { - return $this->raiseError(MDB_ERROR_INVALID, '', '', - 'Get column names: it was specified an inexisting result set'); + return($this->raiseError(MDB_ERROR_INVALID, '', '', + 'Get column names: it was specified an inexisting result set')); } if (!isset($this->columns[$result_value])) { $this->columns[$result_value] = array(); @@ -665,7 +665,7 @@ $this->columns[$result_value][strtolower(fbsql_field_name($result, $column))] = $column; } } - return ($this->columns[$result_value]); + return($this->columns[$result_value]); } // }}} @@ -682,10 +682,10 @@ function numCols($result) { if (!isset($this->highest_fetched_row[intval($result)])) { - return $this->raiseError(MDB_ERROR_INVALID, '', '', - 'numCols: it was specified an inexisting result set'); + return($this->raiseError(MDB_ERROR_INVALID, '', '', + 'numCols: it was specified an inexisting result set')); } - return (fbsql_num_fields($result)); + return(fbsql_num_fields($result)); } // }}} @@ -701,10 +701,10 @@ function endOfResult($result) { if (!isset($this->highest_fetched_row[$result])) { - return $this->raiseError(MDB_ERROR, '', '', - 'End of result: attempted to check the end of an unknown result'); + return($this->raiseError(MDB_ERROR, '', '', + 'End of result: attempted to check the end of an unknown result')); } - return ($this->highest_fetched_row[$result] >= $this->numRows($result)-1); + return($this->highest_fetched_row[$result] >= $this->numRows($result)-1); } // }}} @@ -724,9 +724,9 @@ $this->highest_fetched_row[$result] = max($this->highest_fetched_row[$result], $row); $res = @fbsql_result($result, $row, $field); if ($res === FALSE && $res != NULL) { - return $this->fbsqlRaiseError($errno); + return($this->fbsqlRaiseError($errno)); } - return ($res); + return($res); } // }}} @@ -744,7 +744,7 @@ */ function fetchClob($result, $row, $field) { - return ($this->fetchLob($result, $row, $field)); + return($this->fetchLob($result, $row, $field)); } // }}} @@ -761,7 +761,7 @@ */ function fetchBlob($result, $row, $field) { - return ($this->fetchLob($result, $row, $field)); + return($this->fetchLob($result, $row, $field)); } // }}} @@ -779,19 +779,19 @@ { switch($type) { case MDB_TYPE_BOOLEAN: - return (strcmp($value, 'Y') ? 0 : 1); + return(strcmp($value, 'Y') ? 0 : 1); case MDB_TYPE_DECIMAL: - return (sprintf('%.'.$this->decimal_places.'f', doubleval($value)/$this->decimal_factor)); + return(sprintf('%.'.$this->decimal_places.'f', doubleval($value)/$this->decimal_factor)); case MDB_TYPE_FLOAT: - return (doubleval($value)); + return(doubleval($value)); case MDB_TYPE_DATE: - return ($value); + return($value); case MDB_TYPE_TIME: - return ($value); + return($value); case MDB_TYPE_TIMESTAMP: - return ($value); + return($value); default: - return ($this->_baseConvertResult($value, $type)); + return($this->_baseConvertResult($value, $type)); } } @@ -807,7 +807,7 @@ */ function numRows($result) { - return (fbsql_num_rows($result)); + return(fbsql_num_rows($result)); } // }}} @@ -831,7 +831,7 @@ if(isset($this->result_types[$result])) { unset($this->result_types[$result]); } - return (fbsql_free_result($result)); + return(fbsql_free_result($result)); } // }}} @@ -865,7 +865,7 @@ */ function getIntegerDeclaration($name, $field) { - return ("$name INT". + return("$name INT". (isset($field['unsigned']) ? ' UNSIGNED' : ''). (isset($field['default']) ? ' DEFAULT '.$field['default'] : ''). (isset($field['notnull']) ? ' NOT NULL' : '') @@ -906,7 +906,7 @@ } else { $type = 'VARCHAR(32768)'; } - return ("$name $type". + return("$name $type". (isset($field['notnull']) ? ' NOT NULL' : '')); } @@ -945,7 +945,7 @@ else { $type = 'BLOB(32768)'; } - return ("$name $type". + return("$name $type". (isset($field['notnull']) ? ' NOT NULL' : '')); } @@ -974,7 +974,7 @@ */ function getDateDeclaration($name, $field) { - return ("$name DATE". + return("$name DATE". (isset($field['default']) ? " DEFAULT DATE'".$field['default']."'" : ''). (isset($field['notnull']) ? ' NOT NULL' : '') ); @@ -1006,7 +1006,7 @@ */ function getTimestampDeclaration($name, $field) { - return ("$name DATETIME". + return("$name DATETIME". (isset($field['default']) ? " DEFAULT TIMESTAMP'".$field['default']."'" : ''). (isset($field['notnull']) ? ' NOT NULL' : '') ); @@ -1037,7 +1037,7 @@ */ function getTimeDeclaration($name, $field) { - return ("$name TIME". + return("$name TIME". (isset($field['default']) ? " DEFAULT TIME'".$field['default']."'" : ''). (isset($field['notnull']) ? ' NOT NULL' : '') ); @@ -1077,7 +1077,7 @@ $this->connect(); } } - return ("$name DOUBLE". + return("$name DOUBLE". ($this->fixed_float ? '('.($this->fixed_float + 2).','.$this->fixed_float.')' : ''). (isset($field['default']) ? @@ -1112,7 +1112,7 @@ */ function getDecimalDeclaration($name, $field) { - return ("$name REAL". + return("$name REAL". (isset($field['default']) ? ' DEFAULT '.$this->getDecimalValue($field['default']) : ''). (isset($field['notnull']) ? ' NOT NULL' : '') @@ -1138,12 +1138,12 @@ $value = "'"; while(!$this->endOfLob($clob)) { if (MDB::isError($result = $this->readLob($clob, $data, $this->options['lob_buffer_length']))) { - return $result; + return($result); } $value .= $this->_quote($data); } $value .= "'"; - return ($value); + return($value); } // }}} @@ -1160,7 +1160,7 @@ function freeClobValue($prepared_query, $clob) { unset($this->lobs[$clob]); - return (MDB_OK); + return(MDB_OK); } // }}} @@ -1182,12 +1182,12 @@ $value = "'"; while(!$this->endOfLob($blob)) { if (MDB::isError($result = $this->readLob($blob, $data, $this->options['lob_buffer_length']))) { - return $result; + return($result); } $value .= addslashes($data); } $value .= "'"; - return ($value); + return($value); } // }}} @@ -1204,7 +1204,7 @@ function freeBlobValue($prepared_query, $blob) { unset($this->lobs[$blob]); - return (MDB_OK); + return(MDB_OK); } // }}} @@ -1221,7 +1221,7 @@ */ function getFloatValue($value) { - return (!strcmp($value, 'NULL') ? 'NULL' : "$value"); + return(!strcmp($value, 'NULL') ? 'NULL' : "$value"); } // }}} @@ -1238,7 +1238,7 @@ */ function getDecimalValue($value) { - return (!strcmp($value, 'NULL') ? 'NULL' : strval(round(doubleval($value)*$this->decimal_factor))); + return(!strcmp($value, 'NULL') ? 'NULL' : strval(round(doubleval($value)*$this->decimal_factor))); } // }}} @@ -1267,11 +1267,11 @@ // we know the first id = 1 so initialize the // sequence at 2 if (MDB::isError($result)) { - return $this->raiseError(MDB_ERROR, '', '', - 'Next ID: on demand sequence could not be created'); + return($this->raiseError(MDB_ERROR, '', '', + 'Next ID: on demand sequence could not be created')); } else { // First ID of a newly created sequence is 1 - return 1; + return(1); } } $value = intval(fbsql_insert_id()); @@ -1279,7 +1279,7 @@ if (MDB::isError($res)) { $this->warnings[] = 'Next ID: could not delete previous sequence table values'; } - return ($value); + return($value); } @@ -1298,10 +1298,10 @@ $sequence_name = $this->getSequenceName($seq_name); $result = $this->query("SELECT MAX(sequence) FROM $sequence_name", 'integer'); if (MDB::isError($result)) { - return $result; + return($result); } - return ($this->fetchOne($result)); + return($this->fetchOne($result)); } // }}} @@ -1316,13 +1316,13 @@ * @return int data array on success, a MDB error on failure * @access public */ - function fetchInto($result, $fetchmode = MDB_FETCHMODE_DEFAULT, $rownum = NULL) + function fetchInto($result, $fetchmode = MDB_FETCHMODE_DEFAULT, $rownum = 0) { - if ($rownum == NULL) { + if ($rownum == 0) { ++$this->highest_fetched_row[$result]; } else { if (!@fbsql_data_seek($result, $rownum)) { - return NULL; + return(NULL); } $this->highest_fetched_row[$result] = max($this->highest_fetched_row[$result], $rownum); } @@ -1340,14 +1340,14 @@ if($this->options['autofree']) { $this->freeResult($result); } - return NULL; + return(NULL); } - return $this->fbsqlRaiseError($errno); + return($this->fbsqlRaiseError($errno)); } if (isset($this->result_types[$result])) { $array = $this->convertResultRow($result, $array); } - return ($array); + return($array); } // }}} @@ -1363,7 +1363,7 @@ */ function nextResult($result) { - return FALSE; + return(FALSE); } // }}} @@ -1425,12 +1425,12 @@ $id = @fbsql_list_fields($this->database_name, $result, $this->connection); if (empty($id)) { - return $this->fbsqlRaiseError(); + return($this->fbsqlRaiseError()); } } else { // else we want information about a resultset $id = $result; if (empty($id)) { - return $this->fbsqlRaiseError(); + return($this->fbsqlRaiseError()); } } @@ -1467,7 +1467,7 @@ if (is_string($result)) { @fbsql_free_result($id); } - return $res; + return($res); } } Index: pear/MDB/MDB/Common.php diff -u pear/MDB/MDB/Common.php:1.86 pear/MDB/MDB/Common.php:1.87 --- pear/MDB/MDB/Common.php:1.86 Sat Jan 18 16:37:16 2003 +++ pear/MDB/MDB/Common.php Sun Jan 19 06:12:43 2003 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.86 2003/01/18 21:37:16 lsmith Exp $ +// $Id: Common.php,v 1.87 2003/01/19 11:12:43 lsmith Exp $ /** * @package MDB @@ -544,7 +544,11 @@ if (strlen($included_constant) == 0 || !defined($included_constant)) { if($include) { $include = 'MDB/Modules/'.$include; - include_once($include); + if(MDB::isError($debug = $this->getOption('debug')) || $debug > 2) { + include_once($include); + } else { + @include_once($include); + } } else { return($this->raiseError(MDB_ERROR_LOADMODULE, '', '', $scope . ': it was not specified an existing ' . $module . ' file (' . $include . ')')); @@ -3540,7 +3544,7 @@ * @return mixed data array on success, a MDB error on failure * @access public */ - function fetchRow($result, $fetchmode = MDB_FETCHMODE_DEFAULT, $rownum = NULL) + function fetchRow($result, $fetchmode = MDB_FETCHMODE_DEFAULT, $rownum = 0) { $res = $this->fetchInto($result, $fetchmode, $rownum); if (!$this->options['autofree'] && $res != NULL) { @@ -3564,7 +3568,7 @@ { $fetchmode = is_int($colnum) ? MDB_FETCHMODE_ORDERED : MDB_FETCHMODE_ASSOC; $column = array(); - while (is_array($res = $this->fetchInto($result, $fetchmode, NULL))) { + while (is_array($res = $this->fetchInto($result, $fetchmode))) { $column[] = $res[$colnum]; } if (!$this->options['autofree'] && $res != NULL) { @@ -3608,7 +3612,7 @@ } } $all = array(); - while (is_array($res = $this->fetchInto($result, $fetchmode, NULL))) { + while (is_array($res = $this->fetchInto($result, $fetchmode))) { if ($rekey) { if ($fetchmode & MDB_FETCHMODE_ASSOC) { reset($res); Index: pear/MDB/MDB/Modules/Manager/pgsql.php diff -u pear/MDB/MDB/Modules/Manager/pgsql.php:1.32 pear/MDB/MDB/Modules/Manager/pgsql.php:1.33 --- pear/MDB/MDB/Modules/Manager/pgsql.php:1.32 Tue Dec 3 06:29:08 2002 +++ pear/MDB/MDB/Modules/Manager/pgsql.php Sun Jan 19 06:12:44 2003 @@ -42,13 +42,13 @@ // | Author: Paul Cooper <pgc@ucecom.com> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.32 2002/12/03 11:29:08 lsmith Exp $ +// $Id: pgsql.php,v 1.33 2003/01/19 11:12:44 lsmith Exp $ if(!defined('MDB_MANAGER_PGSQL_INCLUDED')) { define('MDB_MANAGER_PGSQL_INCLUDED', 1); -require_once 'MDB/Modules/Manager/Common.php'; +require_once('MDB/Modules/Manager/Common.php'); /** * MDB MySQL driver for the management modules @@ -128,16 +128,16 @@ function createTable(&$db, $name, $fields) { if (!isset($name) || !strcmp($name, '')) { - return $db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no valid table name specified'); + return($db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no valid table name specified')); } if (count($fields) == 0) { - return $db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no fields specified for table "' . $name . '"'); + return($db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no fields specified for table "'.$name.'"')); } $query_fields = ''; if (MDB::isError($query_fields = $db->getFieldDeclarationList($fields))) { - return $db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'unkown error'); + return($db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'unkown error')); } - return ($db->query("CREATE TABLE $name ($query_fields)")); + return($db->query("CREATE TABLE $name ($query_fields)")); } // }}} @@ -254,10 +254,10 @@ return($db->raiseError(MDB_ERROR_UNSUPPORTED, '', '', 'change type "'.key($changes).'\" not yet supported')); } } - return (MDB_OK); + return(MDB_OK); } else { if (isSet($changes[$change = 'name']) || isSet($changes[$change = 'RenamedFields']) || isSet($changes[$change = 'ChangedFields'])) { - return($db->raiseError(MDB_ERROR_UNSUPPORTED, '', '', "change type \"$change\" not yet supported")); + return($db->raiseError(MDB_ERROR_UNSUPPORTED, '', '', 'change type "'.$change.'" not yet supported')); } $query = ''; if (isSet($changes['AddedFields'])) { @@ -276,7 +276,7 @@ } } } - return (MDB_OK); + return(MDB_OK); } } @@ -292,7 +292,7 @@ **/ function listDatabases(&$db) { - return $db->queryCol('SELECT datname FROM pg_database'); + return($db->queryCol('SELECT datname FROM pg_database')); } // }}} @@ -307,7 +307,7 @@ **/ function listUsers(&$db) { - return $db->queryCol('SELECT usename FROM pg_user'); + return($db->queryCol('SELECT usename FROM pg_user')); } // }}} @@ -335,7 +335,7 @@ AND not exists (select 1 from pg_views where viewname = c.relname) AND not exists (select 1 from pg_user where usesysid = c.relowner) AND c.relname !~ \'^pg_\''; - return $db->queryCol($sql); + return($db->queryCol($sql)); } // }}} @@ -353,13 +353,13 @@ { $result = $db->query("SELECT * FROM $table"); if(MDB::isError($result)) { - return $result; + return($result); } $columns = $db->getColumnNames($result); if(MDB::isError($columns)) { $db->freeResult($columns); } - return $columns; + return($columns); } // }}} @@ -378,7 +378,7 @@ function listViews(&$db) { // gratuitously stolen from PEAR DB _getSpecialQuery in pgsql.php - return $db->queryCol('SELECT viewname FROM pg_views'); + return($db->queryCol('SELECT viewname FROM pg_views')); } // }}} @@ -447,7 +447,7 @@ AND not exists (select 1 from pg_views where viewname = c.relname) AND not exists (select 1 from pg_user where usesysid = c.relowner) AND c.relname !~ \'^pg_\''; - return $db->queryCol($sql); + return($db->queryCol($sql)); } } Index: pear/MDB/MDB/Modules/Manager/mysql.php diff -u pear/MDB/MDB/Modules/Manager/mysql.php:1.40 pear/MDB/MDB/Modules/Manager/mysql.php:1.41 --- pear/MDB/MDB/Modules/Manager/mysql.php:1.40 Tue Dec 3 06:30:45 2002 +++ pear/MDB/MDB/Modules/Manager/mysql.php Sun Jan 19 06:12:44 2003 @@ -42,14 +42,14 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.40 2002/12/03 11:30:45 lsmith Exp $ +// $Id: mysql.php,v 1.41 2003/01/19 11:12:44 lsmith Exp $ // if(!defined('MDB_MANAGER_MYSQL_INCLUDED')) { define('MDB_MANAGER_MYSQL_INCLUDED', 1); -require_once 'MDB/Modules/Manager/Common.php'; +require_once('MDB/Modules/Manager/Common.php'); /** * MDB MySQL driver for the management modules @@ -113,7 +113,7 @@ } if(count($has) == 0) { return($db->raiseError(MDB_ERROR_UNSUPPORTED, '', '', - 'Verify transactional table',"could not tell if ".$table_type.' is a supported table type')); + 'Verify transactional table','could not tell if '.$table_type.' is a supported table type')); } if(strcmp($has[0][1], 'YES')) { return($db->raiseError(MDB_ERROR_UNSUPPORTED, '', '', @@ -121,7 +121,7 @@ $table_type.' is not a supported table type by this MySQL database server')); } $this->verified_table_types[$table_type] = $db->connection; - return (MDB_OK); + return(MDB_OK); } // }}} @@ -138,14 +138,14 @@ function createDatabase(&$db, $name) { if (MDB::isError($result = $db->connect())) { - return $result; + return($result); } - $query = "CREATE DATABASE " . $name; + $query = 'CREATE DATABASE '.$name; if(MDB::isError($db->query($query))) { - return $db->mysqlRaiseError(); + return($db->mysqlRaiseError()); } - return (MDB_OK); + return(MDB_OK); } // }}} @@ -162,13 +162,13 @@ function dropDatabase(&$db, $name) { if (MDB::isError($result = $db->connect())) { - return $result; + return($result); } - $query = "DROP DATABASE " . $name; + $query = 'DROP DATABASE '.$name; if(MDB::isError($db->query($query))) { - return $db->mysqlRaiseError(); + return($db->mysqlRaiseError()); } - return (MDB_OK); + return(MDB_OK); } // }}} @@ -208,16 +208,16 @@ function createTable(&$db, $name, $fields) { if (!isset($name) || !strcmp($name, '')) { - return $db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no valid table name specified'); + return($db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no valid table name specified')); } if (count($fields) == 0) { - return $db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no fields specified for table "'.$name.'"'); + return($db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no fields specified for table "'.$name.'"')); } if(MDB::isError($verify = $this->_verifyTransactionalTableType($db, $db->default_table_type))) { return($verify); } if (MDB::isError($query_fields = $db->getFieldDeclarationList($fields))) { - return $db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'unkown error'); + return($db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'unkown error')); } if (isset($db->supported['Transactions']) && $db->default_table_type=='BDB') @@ -226,7 +226,7 @@ } $query = "CREATE TABLE $name ($query_fields)".(strlen($db->default_table_type) ? ' TYPE='.$db->default_table_type : ''); - return ($db->query($query)); + return($db->query($query)); } // }}} @@ -344,11 +344,11 @@ case 'name': break; default: - return $db->raiseError(MDB_ERROR_CANNOT_ALTER, '', '', - 'Alter table: change type "'.Key($changes).'" not yet supported'); + return($db->raiseError(MDB_ERROR_CANNOT_ALTER, '', '', + 'Alter table: change type "'.Key($changes).'" not yet supported')); } } - return (MDB_OK); + return(MDB_OK); } else { $query = (isset($changes['name']) ? 'RENAME AS '.$changes['name'] : ''); if (isset($changes['AddedFields'])) { @@ -416,7 +416,7 @@ $query .= "CHANGE $old_field_name ".$changes['RenamedFields'][$old_field_name]['Declaration']; } } - return ($db->query("ALTER TABLE $name $query")); + return($db->query("ALTER TABLE $name $query")); } } @@ -434,9 +434,9 @@ { $result = $db->queryCol('SHOW DATABASES'); if(MDB::isError($result)) { - return $result; + return($result); } - return ($result); + return($result); } // }}} @@ -453,9 +453,9 @@ { $result = $db->queryCol('SELECT DISTINCT USER FROM USER'); if(MDB::isError($result)) { - return $result; + return($result); } - return ($result); + return($result); } // }}} @@ -472,14 +472,14 @@ { $table_names = $db->queryCol('SHOW TABLES'); if(MDB::isError($table_names)) { - return $table_names; + return($table_names); } for($i = 0, $j = count($table_names), $tables = array(); $i < $j; ++$i) { if (!$db->_isSequenceName($table_names[$i])) $tables[] = $table_names[$i]; } - return ($tables); + return($tables); } // }}} @@ -497,17 +497,17 @@ { $result = $db->query("SHOW COLUMNS FROM $table"); if(MDB::isError($result)) { - return $result; + return($result); } $columns = $db->getColumnNames($result); if(MDB::isError($columns)) { $db->freeResult($columns); - return $columns; + return($columns); } if(!isset($columns['field'])) { $db->freeResult($result); - return $db->raiseError(MDB_ERROR_MANAGER, '', '', - 'List table fields: show columns does not return the table field names'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', + 'List table fields: show columns does not return the table field names')); } $field_column = $columns['field']; for($fields = array(), $field = 0; !$db->endOfResult($result); ++$field) { @@ -516,7 +516,7 @@ $fields[] = $field_name; } $db->freeResult($result); - return ($fields); + return($fields); } // }}} @@ -534,24 +534,24 @@ function getTableFieldDefinition(&$db, $table, $field_name) { if ($field_name == $db->dummy_primary_key) { - return $db->raiseError(MDB_ERROR_MANAGER, '', '', - 'Get table field definiton: '.$db->dummy_primary_key.' is an hidden column'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', + 'Get table field definiton: '.$db->dummy_primary_key.' is an hidden column')); } $result = $db->query("SHOW COLUMNS FROM $table"); if(MDB::isError($result)) { - return $result; + return($result); } $columns = $db->getColumnNames($result); if(MDB::isError($columns)) { $db->freeResult($columns); - return $columns; + return($columns); } if (!isset($columns[$column = 'field']) || !isset($columns[$column = 'type'])) { $db->freeResult($result); - return $db->raiseError(MDB_ERROR_MANAGER, '', '', - 'Get table field definition: show columns does not return the column '.$column); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', + 'Get table field definition: show columns does not return the column '.$column)); } $field_column = $columns['field']; $type_column = $columns['type']; @@ -641,8 +641,8 @@ $type[1] = 'date'; break; default: - return $db->raiseError(MDB_ERROR_MANAGER, '', '', - 'List table fields: unknown database attribute type'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', + 'List table fields: unknown database attribute type')); } unset($notnull); if (isset($columns['null']) @@ -711,7 +711,7 @@ } } $db->freeResult($result); - return ($definition); + return($definition); } } if(!$db->options['autofree']) { @@ -720,8 +720,8 @@ if(MDB::isError($row)) { return($row); } - return $db->raiseError(MDB_ERROR_MANAGER, '', '', - 'Get table field definition: it was not specified an existing table column'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', + 'Get table field definition: it was not specified an existing table column')); } // }}} @@ -773,7 +773,7 @@ $query .= key($definition['FIELDS']); } $query .= ')'; - return ($db->query($query)); + return($db->query($query)); } // }}} @@ -790,7 +790,7 @@ */ function dropIndex(&$db, $table, $name) { - return ($db->query("ALTER TABLE $table DROP INDEX $name")); + return($db->query("ALTER TABLE $table DROP INDEX $name")); } // }}} @@ -840,7 +840,7 @@ function getTableIndexDefinition(&$db, $table, $index_name) { if($index_name == 'PRIMARY') { - return $db->raiseError(MDB_ERROR_MANAGER, '', '', 'Get table index definition: PRIMARY is an hidden index'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', 'Get table index definition: PRIMARY is an hidden index')); } if(MDB::isError($result = $db->query("SHOW INDEX FROM $table"))) { return($result); @@ -861,9 +861,9 @@ } $db->freeResult($result); if (!isset($definition['FIELDS'])) { - return $db->raiseError(MDB_ERROR_MANAGER, '', '', 'Get table index definition: it was not specified an existing table index'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', 'Get table index definition: it was not specified an existing table index')); } - return ($definition); + return($definition); } // }}} @@ -884,25 +884,25 @@ $res = $db->query("CREATE TABLE $sequence_name (sequence INT DEFAULT 0 NOT NULL AUTO_INCREMENT, PRIMARY KEY (sequence))"); if (MDB::isError($res)) { - return $res; + return($res); } if ($start == 1) { - return MDB_OK; + return(MDB_OK); } - $res = $db->query("INSERT INTO $sequence_name (sequence) VALUES (".($start-1).")"); + $res = $db->query("INSERT INTO $sequence_name (sequence) VALUES (".($start-1).')'); if (!MDB::isError($res)) { - return MDB_OK; + return(MDB_OK); } // Handle error $result = $db->query("DROP TABLE $sequence_name"); if (MDB::isError($result)) { - return $db->raiseError(MDB_ERROR, '', '', + return($db->raiseError(MDB_ERROR, '', '', 'Create sequence: could not drop inconsistent sequence table ('. - $result->getMessage().' ('.$result->getUserinfo().'))'); + $result->getMessage().' ('.$result->getUserinfo().'))')); } - return $db->raiseError(MDB_ERROR, '', '', + return($db->raiseError(MDB_ERROR, '', '', 'Create sequence: could not create sequence table ('. - $res->getMessage().' ('.$res->getUserinfo().'))'); + $res->getMessage().' ('.$res->getUserinfo().'))')); } // }}} @@ -919,7 +919,7 @@ function dropSequence(&$db, $seq_name) { $sequence_name = $db->getSequenceName($seq_name); - return ($db->query("DROP TABLE $sequence_name")); + return($db->query("DROP TABLE $sequence_name")); } // }}} @@ -936,14 +936,14 @@ { $table_names = $db->queryCol('SHOW TABLES'); if(MDB::isError($table_names)) { - return $table_names; + return($table_names); } for($i = 0, $j = count($table_names), $sequences = array(); $i < $j; ++$i) { if ($sqn = $db->_isSequenceName($table_names[$i])) $sequences[] = $sqn; } - return ($sequences); + return($sequences); } // }}} Index: pear/MDB/MDB/Modules/Manager/fbsql.php diff -u pear/MDB/MDB/Modules/Manager/fbsql.php:1.1 pear/MDB/MDB/Modules/Manager/fbsql.php:1.2 --- pear/MDB/MDB/Modules/Manager/fbsql.php:1.1 Thu Dec 26 16:38:05 2002 +++ pear/MDB/MDB/Modules/Manager/fbsql.php Sun Jan 19 06:12:44 2003 @@ -42,14 +42,14 @@ // | Author: Lukas Smith <smith@dybnet.de> | // +----------------------------------------------------------------------+ // -// $Id: fbsql.php,v 1.1 2002/12/26 21:38:05 fmk Exp $ +// $Id: fbsql.php,v 1.2 2003/01/19 11:12:44 lsmith Exp $ // if(!defined('MDB_MANAGER_FBSQL_INCLUDED')) { define('MDB_MANAGER_FBSQL_INCLUDED', 1); -require_once 'MDB/Modules/Manager/Common.php'; +require_once('MDB/Modules/Manager/Common.php'); /** * MDB FrontBase driver for the management modules @@ -114,7 +114,7 @@ } if(count($has) == 0) { return($db->raiseError(MDB_ERROR_UNSUPPORTED, '', '', - 'Verify transactional table',"could not tell if ".$table_type.' is a supported table type')); + 'Verify transactional table','could not tell if '.$table_type.' is a supported table type')); } if(strcmp($has[0][1], 'YES')) { return($db->raiseError(MDB_ERROR_UNSUPPORTED, '', '', @@ -122,7 +122,7 @@ $table_type.' is not a supported table type by this FrontBase database server')); } $this->verified_table_types[$table_type] = $db->connection; - return (MDB_OK); + return(MDB_OK); } // }}} @@ -139,13 +139,13 @@ function createDatabase(&$db, $name) { if (MDB::isError($result = $db->connect())) { - return $result; + return($result); } if (!fbsql_create_db($name, $db->connection)) { - return $db->fbsqlRaiseError(); + return($db->fbsqlRaiseError()); } - return (MDB_OK); + return(MDB_OK); } // }}} @@ -162,12 +162,12 @@ function dropDatabase(&$db, $name) { if (MDB::isError($result = $db->connect())) { - return $result; + return($result); } if (!fbsql_drop_db($name, $db->connection)) { - return $db->fbsqlRaiseError(); + return($db->fbsqlRaiseError()); } - return (MDB_OK); + return(MDB_OK); } // }}} @@ -207,16 +207,16 @@ function createTable(&$db, $name, $fields) { if (!isset($name) || !strcmp($name, '')) { - return $db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no valid table name specified'); + return($db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no valid table name specified')); } if (count($fields) == 0) { - return $db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no fields specified for table "'.$name.'"'); + return($db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'no fields specified for table "'.$name.'"')); } if(MDB::isError($verify = $this->_verifyTransactionalTableType($db, $db->default_table_type))) { return($verify); } if (MDB::isError($query_fields = $db->getFieldDeclarationList($fields))) { - return $db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'unkown error'); + return($db->raiseError(MDB_ERROR_CANNOT_CREATE, '', '', 'unkown error')); } if (isset($db->supported['Transactions']) && $db->default_table_type=='BDB') @@ -225,7 +225,7 @@ } $query = "CREATE TABLE $name ($query_fields)".(strlen($db->default_table_type) ? ' TYPE='.$db->default_table_type : ''); - return ($db->query($query)); + return($db->query($query)); } // }}} @@ -343,11 +343,11 @@ case 'name': break; default: - return $db->raiseError(MDB_ERROR_CANNOT_ALTER, '', '', - 'Alter table: change type "'.Key($changes).'" not yet supported'); + return($db->raiseError(MDB_ERROR_CANNOT_ALTER, '', '', + 'Alter table: change type "'.Key($changes).'" not yet supported')); } } - return (MDB_OK); + return(MDB_OK); } else { $query = (isset($changes['name']) ? 'RENAME AS '.$changes['name'] : ''); if (isset($changes['AddedFields'])) { @@ -415,7 +415,7 @@ $query .= "CHANGE $old_field_name ".$changes['RenamedFields'][$old_field_name]['Declaration']; } } - return ($db->query("ALTER TABLE $name $query")); + return($db->query("ALTER TABLE $name $query")); } } @@ -433,9 +433,9 @@ { $result = $db->queryCol('SHOW DATABASES'); if(MDB::isError($result)) { - return $result; + return($result); } - return ($result); + return($result); } // }}} @@ -452,9 +452,9 @@ { $result = $db->queryCol('SELECT DISTINCT USER FROM USER'); if(MDB::isError($result)) { - return $result; + return($result); } - return ($result); + return($result); } // }}} @@ -471,14 +471,14 @@ { $table_names = $db->queryCol('SHOW TABLES'); if(MDB::isError($table_names)) { - return $table_names; + return($table_names); } for($i = 0, $j = count($table_names), $tables = array(); $i < $j; ++$i) { if (!$db->_isSequenceName($table_names[$i])) $tables[] = $table_names[$i]; } - return ($tables); + return($tables); } // }}} @@ -496,17 +496,17 @@ { $result = $db->query("SHOW COLUMNS FROM $table"); if(MDB::isError($result)) { - return $result; + return($result); } $columns = $db->getColumnNames($result); if(MDB::isError($columns)) { $db->freeResult($columns); - return $columns; + return($columns); } if(!isset($columns['field'])) { $db->freeResult($result); - return $db->raiseError(MDB_ERROR_MANAGER, '', '', - 'List table fields: show columns does not return the table field names'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', + 'List table fields: show columns does not return the table field names')); } $field_column = $columns['field']; for($fields = array(), $field = 0; !$db->endOfResult($result); ++$field) { @@ -515,7 +515,7 @@ $fields[] = $field_name; } $db->freeResult($result); - return ($fields); + return($fields); } // }}} @@ -533,24 +533,24 @@ function getTableFieldDefinition(&$db, $table, $field_name) { if ($field_name == $db->dummy_primary_key) { - return $db->raiseError(MDB_ERROR_MANAGER, '', '', - 'Get table field definiton: '.$db->dummy_primary_key.' is an hidden column'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', + 'Get table field definiton: '.$db->dummy_primary_key.' is an hidden column')); } $result = $db->query("SHOW COLUMNS FROM $table"); if(MDB::isError($result)) { - return $result; + return($result); } $columns = $db->getColumnNames($result); if(MDB::isError($columns)) { $db->freeResult($columns); - return $columns; + return($columns); } if (!isset($columns[$column = 'field']) || !isset($columns[$column = 'type'])) { $db->freeResult($result); - return $db->raiseError(MDB_ERROR_MANAGER, '', '', - 'Get table field definition: show columns does not return the column '.$column); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', + 'Get table field definition: show columns does not return the column '.$column)); } $field_column = $columns['field']; $type_column = $columns['type']; @@ -640,8 +640,8 @@ $type[1] = 'date'; break; default: - return $db->raiseError(MDB_ERROR_MANAGER, '', '', - 'List table fields: unknown database attribute type'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', + 'List table fields: unknown database attribute type')); } unset($notnull); if (isset($columns['null']) @@ -710,7 +710,7 @@ } } $db->freeResult($result); - return ($definition); + return($definition); } } if(!$db->options['autofree']) { @@ -719,8 +719,8 @@ if(MDB::isError($row)) { return($row); } - return $db->raiseError(MDB_ERROR_MANAGER, '', '', - 'Get table field definition: it was not specified an existing table column'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', + 'Get table field definition: it was not specified an existing table column')); } // }}} @@ -772,7 +772,7 @@ $query .= key($definition['FIELDS']); } $query .= ')'; - return ($db->query($query)); + return($db->query($query)); } // }}} @@ -789,7 +789,7 @@ */ function dropIndex(&$db, $table, $name) { - return ($db->query("ALTER TABLE $table DROP INDEX $name")); + return($db->query("ALTER TABLE $table DROP INDEX $name")); } // }}} @@ -839,7 +839,7 @@ function getTableIndexDefinition(&$db, $table, $index_name) { if($index_name == 'PRIMARY') { - return $db->raiseError(MDB_ERROR_MANAGER, '', '', 'Get table index definition: PRIMARY is an hidden index'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', 'Get table index definition: PRIMARY is an hidden index')); } if(MDB::isError($result = $db->query("SHOW INDEX FROM $table"))) { return($result); @@ -860,9 +860,9 @@ } $db->freeResult($result); if (!isset($definition['FIELDS'])) { - return $db->raiseError(MDB_ERROR_MANAGER, '', '', 'Get table index definition: it was not specified an existing table index'); + return($db->raiseError(MDB_ERROR_MANAGER, '', '', 'Get table index definition: it was not specified an existing table index')); } - return ($definition); + return($definition); } // }}} @@ -883,25 +883,25 @@ $res = $db->query("CREATE TABLE $sequence_name (sequence INT DEFAULT 0 NOT NULL AUTO_INCREMENT, PRIMARY KEY (sequence))"); if (MDB::isError($res)) { - return $res; + return($res); } if ($start == 1) { - return MDB_OK; + return(MDB_OK); } - $res = $db->query("INSERT INTO $sequence_name (sequence) VALUES (".($start-1).")"); + $res = $db->query("INSERT INTO $sequence_name (sequence) VALUES (".($start-1).')'); if (!MDB::isError($res)) { - return MDB_OK; + return(MDB_OK); } // Handle error $result = $db->query("DROP TABLE $sequence_name"); if (MDB::isError($result)) { - return $db->raiseError(MDB_ERROR, '', '', + return($db->raiseError(MDB_ERROR, '', '', 'Create sequence: could not drop inconsistent sequence table ('. - $result->getMessage().' ('.$result->getUserinfo().'))'); + $result->getMessage().' ('.$result->getUserinfo().'))')); } - return $db->raiseError(MDB_ERROR, '', '', + return($db->raiseError(MDB_ERROR, '', '', 'Create sequence: could not create sequence table ('. - $res->getMessage().' ('.$res->getUserinfo().'))'); + $res->getMessage().' ('.$res->getUserinfo().'))')); } // }}} @@ -918,7 +918,7 @@ function dropSequence(&$db, $seq_name) { $sequence_name = $db->getSequenceName($seq_name); - return ($db->query("DROP TABLE $sequence_name")); + return($db->query("DROP TABLE $sequence_name")); } // }}} @@ -935,14 +935,14 @@ { $table_names = $db->queryCol('SHOW TABLES'); if(MDB::isError($table_names)) { - return $table_names; + return($table_names); } for($i = 0, $j = count($table_names), $sequences = array(); $i < $j; ++$i) { if ($sqn = $db->_isSequenceName($table_names[$i])) $sequences[] = $sqn; } - return ($sequences); + return($sequences); } // }}}
« previous php.pear.cvs (#8404) next »