Update of /cvsroot/phplib/php-lib-stable/php
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18134/php
Modified Files:
db_msql.inc db_mssql.inc db_mysql.inc db_oci8.inc db_odbc.inc
db_oracle.inc db_pgsql.inc db_sybase.inc template.inc
Log Message:
db classes - cleaned up and allowed a bit more flexibility
template.inc - allow alternate variable name regex matching
Index: db_msql.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_msql.inc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** db_msql.inc 14 Mar 2002 20:41:07 -0000 1.4
--- db_msql.inc 23 Jul 2004 20:36:29 -0000 1.5
***************
*** 12,16 ****
*/
! class DB_Sql {
var $Host = "";
var $Database = "";
--- 12,16 ----
*/
! class DB_msql {
var $Host = "";
var $Database = "";
***************
*** 22,25 ****
--- 22,26 ----
var $Error = "";
+ var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore error, but spit a warning)
var $Auto_Free = 0; ## Set this to 1 for automatic msql_free_result()
***************
*** 27,32 ****
/* public: constructor */
! function DB_Sql($query = "") {
$this->query($query);
}
--- 28,35 ----
/* public: constructor */
! function DB_msql($query = "") {
! if($query) {
$this->query($query);
+ }
}
***************
*** 48,60 ****
// Still not connected? Raise error.
if ( 0 == $this->Link_ID ) {
! $this->halt("connect($this->Host) failed.");
}
// Select current database
if (!msql_select_db($this->Database, $this->Link_ID)) {
! $this->halt("cannot use database ".$this->Database);
}
}
!
function query($Query_String) {
--- 51,68 ----
// Still not connected? Raise error.
if ( 0 == $this->Link_ID ) {
! $this->connect_failed("connect ($this->Host) failed");
}
// Select current database
if (!msql_select_db($this->Database, $this->Link_ID)) {
! $this->connect_failed("cannot use database ".$this->Database);
}
}
!
! function connect_failed($message) {
! $this->Halt_On_Error = "yes";
! $this->halt($message);
! }
!
function query($Query_String) {
***************
*** 157,164 ****
function halt($msg) {
! printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>MSQL Error</b>: %s<br>\n", $this->Error);
! die("Session halted.");
}
}
?>
--- 165,193 ----
function halt($msg) {
! if ("no" == $this->Halt_On_Error)
! return;
!
! $this->haltmsg($msg);
!
! if ("report" != $this->Halt_On_Error)
! die("Session halted.");
! }
!
! function haltmsg($msg) {
! printf("<p><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>MSQL Error</b>: %s</p>\n", $this->Error);
}
}
+ $_php_major_version = substr(phpversion(), 0, 1);
+ if((4 > $_php_major_version) or !class_exists("DB_Sql"))
+ {
+ class DB_Sql extends DB_msql
+ {
+ function DB_Sql($query = "")
+ {
+ $this->DB_msql($query);
+ }
+ }
+ }
+ unset($_php_major_version);
?>
Index: db_mssql.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_mssql.inc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** db_mssql.inc 19 Mar 2002 22:26:12 -0000 1.5
--- db_mssql.inc 23 Jul 2004 20:36:29 -0000 1.6
***************
*** 11,15 ****
# echo "<BR>This is using the MSSQL class<BR>";
! class DB_Sql {
var $Host = "";
var $Database = "";
--- 11,15 ----
# echo "<BR>This is using the MSSQL class<BR>";
! class DB_MSSQL {
var $Host = "";
var $Database = "";
***************
*** 24,27 ****
--- 24,28 ----
var $Errno = 0;
var $Error = "";
+ var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore error, but spit a warning)
var $Auto_Free = 0; ## set this to 1 to automatically free results
***************
*** 30,35 ****
/* public: constructor */
! function DB_Sql($query = "") {
$this->query($query);
}
--- 31,38 ----
/* public: constructor */
! function DB_MSSQL($query = "") {
! if($query) {
$this->query($query);
+ }
}
***************
*** 42,50 ****
}
if (!$this->Link_ID)
! $this->halt("connect($this->Host, $this->User, \$Password) failed.");
else
! mssql_select_db($this->Database, $this->Link_ID);
}
}
function free_result(){
mssql_free_result($this->Query_ID);
--- 45,60 ----
}
if (!$this->Link_ID)
! $this->connect_failed("connect ($this->Host, $this->User, \$Password) failed");
else
! if (!mssql_select_db($this->Database, $this->Link_ID)) {
! $this->connect_failed("cannot use database ".$this->Database);
! }
}
}
+ function connect_failed($message) {
+ $this->Halt_On_Error = "yes";
+ $this->halt($message);
+ }
+
function free_result(){
mssql_free_result($this->Query_ID);
***************
*** 162,171 ****
function halt($msg) {
! printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>MSSQL Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
- die("Session halted.");
}
}
?>
--- 172,202 ----
function halt($msg) {
! if ("no" == $this->Halt_On_Error)
! return;
!
! $this->haltmsg($msg);
!
! if ("report" != $this->Halt_On_Error)
! die("Session halted.");
! }
!
! function haltmsg($msg) {
! printf("<p><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>MSSQL Error</b>: %s (%s)</p>\n",
$this->Errno,
$this->Error);
}
}
+ $_php_major_version = substr(phpversion(), 0, 1);
+ if((4 > $_php_major_version) or !class_exists("DB_Sql"))
+ {
+ class DB_Sql extends DB_MSSQL
+ {
+ function DB_Sql($query = "")
+ {
+ $this->DB_MSSQL($query);
+ }
+ }
+ }
+ unset($_php_major_version);
?>
Index: db_mysql.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_mysql.inc,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** db_mysql.inc 7 Aug 2002 19:33:57 -0000 1.11
--- db_mysql.inc 23 Jul 2004 20:36:29 -0000 1.12
***************
*** 10,14 ****
*/
! class DB_Sql {
/* public: connection parameters */
--- 10,14 ----
*/
! class DB_MySQL {
/* public: connection parameters */
***************
*** 21,25 ****
var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result()
var $Debug = 0; ## Set to 1 for debugging messages.
! var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
var $PConnect = 0; ## Set to 1 to use persistent database connections
var $Seq_Table = "db_sequence";
--- 21,25 ----
var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result()
var $Debug = 0; ## Set to 1 for debugging messages.
! var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore error, but spit a warning)
var $PConnect = 0; ## Set to 1 to use persistent database connections
var $Seq_Table = "db_sequence";
***************
*** 44,49 ****
/* public: constructor */
! function DB_Sql($query = "") {
$this->query($query);
}
--- 44,51 ----
/* public: constructor */
! function DB_MySQL($query = "") {
! if($query) {
$this->query($query);
+ }
}
***************
*** 78,87 ****
}
if (!$this->Link_ID) {
! $this->halt("connect($Host, $User, \$Password) failed.");
return 0;
}
if (!@mysql_select_db($Database,$this->Link_ID)) {
! $this->halt("cannot use database ".$Database);
return 0;
}
--- 80,89 ----
}
if (!$this->Link_ID) {
! $this->connect_failed("connect ($Host, $User, \$Password) failed");
return 0;
}
if (!@mysql_select_db($Database,$this->Link_ID)) {
! $this->connect_failed("cannot use database ".$Database);
return 0;
}
***************
*** 91,94 ****
--- 93,101 ----
}
+ function connect_failed($message) {
+ $this->Halt_On_Error = "yes";
+ $this->halt($message);
+ }
+
/* public: discard the query result */
function free() {
***************
*** 411,420 ****
function haltmsg($msg) {
! printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>MySQL Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
}
-
}
?>
--- 418,438 ----
function haltmsg($msg) {
! printf("<p><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>MySQL Error</b>: %s (%s)</p>\n",
$this->Errno,
$this->Error);
}
}
+ $_php_major_version = substr(phpversion(), 0, 1);
+ if((4 > $_php_major_version) or !class_exists("DB_Sql"))
+ {
+ class DB_Sql extends DB_MySQL
+ {
+ function DB_Sql($query = "")
+ {
+ $this->DB_MySQL($query);
+ }
+ }
+ }
+ unset($_php_major_version);
?>
Index: db_oci8.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_oci8.inc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** db_oci8.inc 8 Dec 2003 12:09:59 -0000 1.5
--- db_oci8.inc 23 Jul 2004 20:36:29 -0000 1.6
***************
*** 13,19 ****
*/
! class DB_Sql {
var $Debug = 0;
var $sqoe = 1; // show query on error
var $Database = "";
--- 13,20 ----
*/
! class DB_OCI8 {
var $Debug = 0;
var $sqoe = 1; // show query on error
+ var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
var $Database = "";
***************
*** 30,33 ****
--- 31,38 ----
var $autoCount = 1; // Count num_rows on select
+ var $share_connections = false;
+ var $share_connection_name = "";
+ // Defaults to the class name - set to another class name to share connections among different class extensions
+
var $last_query_text = "";
***************
*** 35,40 ****
/* public: constructor */
! function DB_Sql($query = "") {
! $this->query($query);
}
--- 40,47 ----
/* public: constructor */
! function DB_OCI8($query = "") {
! if($query) {
! $this->query($query);
! }
}
***************
*** 52,61 ****
printf("<br>Connecting to $this->Database...<br>\n");
}
! $this->Link_ID = OCIPLogon("$this->User", "$this->Password", "$this->Database");
if (!$this->Link_ID) {
! $this->halt("Link-ID == false ($this->Link_ID), OCILogon failed");
}
!
if ($this->Debug) {
printf("<br>Obtained the Link_ID: $this->Link_ID<br>\n");
--- 59,83 ----
printf("<br>Connecting to $this->Database...<br>\n");
}
! if($this->share_connections) {
! if(!$this->share_connection_name) {
! $this->share_connection_name = get_class($this) . "_Link_ID";
! } else {
! $this->share_connection_name .= "_Link_ID";
! }
! global ${$this->share_connection_name};
! if(${$this->share_connection_name}) {
! $this->Link_ID = ${$this->share_connection_name};
! return true;
! }
! }
! $this->Link_ID = OCIPLogon($this->User, $this->Password, $this->Database);
if (!$this->Link_ID) {
! $this->connect_failed();
! return false;
}
! if($this->share_connections) {
! ${$this->share_connection_name} = $this->Link_ID;
! }
if ($this->Debug) {
printf("<br>Obtained the Link_ID: $this->Link_ID<br>\n");
***************
*** 64,67 ****
--- 86,94 ----
}
+ function connect_failed() {
+ $this->Halt_On_Error = "yes";
+ $this->halt("connect ($this->User, \$Password, $this->Database) failed");
+ }
+
function free() {
if ($this->Parse) {
***************
*** 80,93 ****
function query($Query_String) {
-
- /* No empty queries, please, since PHP4 chokes on them. */
- if ($Query_String == "") {
- /* The empty query string is passed on from the constructor
- * when calling the class without a query, e.g. in situations
- * like these: '$db = new DB_Sql_Subclass;'
- */
- return 0;
- }
-
$this->connect();
$this->free();
--- 107,110 ----
***************
*** 98,105 ****
} else {
if ($this->autoCommit) {
! OCIExecute($this->Parse, "OCI_COMMIT_ON_SUCCESS");
}
else {
! OCIExecute($this->Parse, "OCI_DEFAULT");
}
if ($this->autoCount) {
--- 115,122 ----
} else {
if ($this->autoCommit) {
! OCIExecute($this->Parse, OCI_COMMIT_ON_SUCCESS);
}
else {
! OCIExecute($this->Parse, OCI_DEFAULT);
}
if ($this->autoCount) {
***************
*** 108,112 ****
/* On $this->num_rows I'm storing the returned rows of the query. */
$this->num_rows = OCIFetchStatement($this->Parse, $aux);
- $this->Parse = OCIParse($this->Link_ID, $Query_String);
OCIExecute($this->Parse, OCI_DEFAULT);
}
--- 125,128 ----
***************
*** 121,125 ****
}
! if ($this->Error["code"] != 1403 && $this->Error["code"] != 0 && $this->sqoe) {
echo "<BR><FONT color=red><B>".$this->Error["message"]."<BR>Query :\"$Query_String\"</B></FONT>";
}
--- 137,141 ----
}
! if ((1403 != $this->Error["code"]) and (0 != $this->Error["code"]) and $this->sqoe) {
echo "<BR><FONT color=red><B>".$this->Error["message"]."<BR>Query :\"$Query_String\"</B></FONT>";
}
***************
*** 155,159 ****
@OCIFetchInto($temp_q_id, $temp_result, OCI_ASSOC+OCI_RETURN_NULLS);
if ($temp_result) {
! return $temp_result['CURRVAL'];
}
else {
--- 171,175 ----
@OCIFetchInto($temp_q_id, $temp_result, OCI_ASSOC+OCI_RETURN_NULLS);
if ($temp_result) {
! return $temp_result["CURRVAL"];
}
else {
***************
*** 172,176 ****
function next_record() {
/* IF clause added to prevent a error when tried to read an empty "$this->Parse". */
! if ($this->num_rows() == $this->Row) {
return 0;
}
--- 188,192 ----
function next_record() {
/* IF clause added to prevent a error when tried to read an empty "$this->Parse". */
! if ($this->autoCount and ($this->num_rows() == $this->Row)) {
return 0;
}
***************
*** 183,187 ****
$errno = OCIError($this->Parse);
if (1403 == $errno) { # 1043 means no more records found
! $this->Error = "";
$this->disconnect();
$stat = 0;
--- 199,203 ----
$errno = OCIError($this->Parse);
if (1403 == $errno) { # 1043 means no more records found
! $this->Error = false;
$this->disconnect();
$stat = 0;
***************
*** 196,206 ****
}
} else {
$totalReg = OCINumcols($this->Parse);
for ($ix = 1; $ix <= $totalReg; $ix++) {
$col = strtoupper(OCIColumnname($this->Parse, $ix));
$colreturn = strtolower($col);
! $this->Record[ "$colreturn" ] = $result["$col"];
if ($this->Debug) {
! echo "<b>[$col]</b>:".$result["$col"]."<br>\n";
}
}
--- 212,224 ----
}
} else {
+ $this->Record = array();
$totalReg = OCINumcols($this->Parse);
for ($ix = 1; $ix <= $totalReg; $ix++) {
$col = strtoupper(OCIColumnname($this->Parse, $ix));
$colreturn = strtolower($col);
! $this->Record[$colreturn] =
! (is_object($result[$col])) ? $result[$col]->load() : $result[$col];
if ($this->Debug) {
! echo "<b>[$col]</b>:".$result[$col]."<br>\n";
}
}
***************
*** 270,288 ****
$i = 0;
while ($this->next_record()) {
! $res[$i]["table"] = $this->Record[table_name];
! $res[$i]["name"] = strtolower($this->Record[column_name]);
! $res[$i]["type"] = $this->Record[data_type];
! $res[$i]["len"] = $this->Record[data_length];
! if ($this->Record[index_name]) {
$res[$i]["flags"] = "INDEX ";
}
! $res[$i]["flags"] .= ( $this->Record[nullable] == 'N') ? '' : 'NOT NULL';
! $res[$i]["format"]= (int)$this->Record[data_precision].",".
! (int)$this->Record[data_scale];
if ("0,0" == $res[$i]["format"]) {
$res[$i]["format"] = '';
}
! $res[$i]["index"] = $this->Record[index_name];
! $res[$i]["chars"] = $this->Record[char_col_decl_length];
if ($full) {
$j = $res[$i]["name"];
--- 288,306 ----
$i = 0;
while ($this->next_record()) {
! $res[$i]["table"] = $this->Record["table_name"];
! $res[$i]["name"] = strtolower($this->Record["column_name"]);
! $res[$i]["type"] = $this->Record["data_type"];
! $res[$i]["len"] = $this->Record["data_length"];
! if ($this->Record["index_name"]) {
$res[$i]["flags"] = "INDEX ";
}
! $res[$i]["flags"] .= ( $this->Record["nullable"] == 'N') ? '' : 'NOT NULL';
! $res[$i]["format"]= (int)$this->Record["data_precision"].",".
! (int)$this->Record["data_scale"];
if ("0,0" == $res[$i]["format"]) {
$res[$i]["format"] = '';
}
! $res[$i]["index"] = $this->Record["index_name"];
! $res[$i]["chars"] = $this->Record["char_col_decl_length"];
if ($full) {
$j = $res[$i]["name"];
***************
*** 304,308 ****
function affected_rows() {
! return $this->num_rows();
}
--- 322,326 ----
function affected_rows() {
! return OCIRowCount($this->Parse);
}
***************
*** 324,332 ****
function f($Name) {
! if (is_object($this->Record[$Name])) {
! return $this->Record[$Name]->load();
! } else {
! return $this->Record[$Name];
! }
}
--- 342,346 ----
function f($Name) {
! return $this->Record[$Name];
}
***************
*** 342,346 ****
if (!@OCIExecute($Query_ID)) {
$this->Error = @OCIError($Query_ID);
! if ($this->Error["code"] == 2289) {
$Query_ID = OCIParse($this->Link_ID, "CREATE SEQUENCE $seqname");
if (!OCIExecute($Query_ID)) {
--- 356,360 ----
if (!@OCIExecute($Query_ID)) {
$this->Error = @OCIError($Query_ID);
! if (2289 == $this->Error["code"]) {
$Query_ID = OCIParse($this->Link_ID, "CREATE SEQUENCE $seqname");
if (!OCIExecute($Query_ID)) {
***************
*** 371,382 ****
function halt($msg) {
! printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>ORACLE Error</b>: %s<br>\n", $this->Error["message"]);
! die("Session halted.");
}
function haltmsg($msg) {
! printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>Oracle Error</b>: %s<br>\n", $this->Error);
}
--- 385,400 ----
function halt($msg) {
! if ($this->Halt_On_Error == "no")
! return;
!
! $this->haltmsg($msg);
!
! if ($this->Halt_On_Error != "report")
! die("Session halted.</body></html>");
}
function haltmsg($msg) {
! printf("<p><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>Oracle Error</b>: %s</p>\n", $this->Error["message"]);
}
***************
*** 421,423 ****
--- 439,453 ----
}
}
+ $_php_major_version = substr(phpversion(), 0, 1);
+ if((4 > $_php_major_version) or !class_exists("DB_Sql"))
+ {
+ class DB_Sql extends DB_OCI8
+ {
+ function DB_Sql($query = "")
+ {
+ $this->DB_OCI8($query);
+ }
+ }
+ }
+ unset($_php_major_version);
?>
Index: db_odbc.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_odbc.inc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** db_odbc.inc 11 Jul 2002 23:47:21 -0000 1.5
--- db_odbc.inc 23 Jul 2004 20:36:29 -0000 1.6
***************
*** 9,13 ****
*/
! class DB_Sql {
/* public: connection parameters */
--- 9,13 ----
*/
! class DB_ODBC {
/* public: connection parameters */
***************
*** 21,25 ****
var $PConnect = 0; ## Set to 1 to use persistent database connections
var $Debug = 0; ## Set to 1 for debugging messages
! var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
var $Seq_Table = "db_sequence"; ## Name of the sequence table
var $Seq_ID_Col = "p_nextid"; ## Name of the Sequence ID column in $Seq_Table
--- 21,25 ----
var $PConnect = 0; ## Set to 1 to use persistent database connections
var $Debug = 0; ## Set to 1 for debugging messages
! var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore error, but spit a warning)
var $Seq_Table = "db_sequence"; ## Name of the sequence table
var $Seq_ID_Col = "p_nextid"; ## Name of the Sequence ID column in $Seq_Table
***************
*** 51,56 ****
/* public: constructor */
! function DB_Sql($query = "") {
$this->query($query);
}
--- 51,58 ----
/* public: constructor */
! function DB_ODBC($query = "") {
! if($query) {
$this->query($query);
+ }
}
***************
*** 84,88 ****
}
if (!$this->Link_ID) {
! $this->halt("connect($this->Database, $this->User, \$Password, $this->UseODBCCursor) failed.");
}
}
--- 86,90 ----
}
if (!$this->Link_ID) {
! $this->connect_failed();
}
}
***************
*** 91,94 ****
--- 93,101 ----
}
+ function connect_failed() {
+ $this->Halt_On_Error = "yes";
+ $this->halt("connect ($this->User, \$Password, $this->Database, $this->UseODBCCursor) failed");
+ }
+
/* public: discard the query result */
function free() {
***************
*** 576,581 ****
function haltmsg($msg) {
! printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>ODBC Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
--- 583,588 ----
function haltmsg($msg) {
! printf("<p><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>ODBC Error</b>: %s (%s)</p>\n",
$this->Errno,
$this->Error);
***************
*** 583,585 ****
--- 590,604 ----
}
+ $_php_major_version = substr(phpversion(), 0, 1);
+ if((4 > $_php_major_version) or !class_exists("DB_Sql"))
+ {
+ class DB_Sql extends DB_ODBC
+ {
+ function DB_Sql($query = "")
+ {
+ $this->DB_ODBC($query);
+ }
+ }
+ }
+ unset($_php_major_version);
?>
Index: db_oracle.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_oracle.inc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** db_oracle.inc 12 Jul 2000 18:22:34 -0000 1.3
--- db_oracle.inc 23 Jul 2004 20:36:29 -0000 1.4
***************
*** 9,13 ****
*/
! class DB_Sql {
var $Debug = false;
var $Home = "/u01/app/oracle/product/8.0.4";
--- 9,13 ----
*/
! class DB_Oracle {
var $Debug = false;
var $Home = "/u01/app/oracle/product/8.0.4";
***************
*** 31,34 ****
--- 31,35 ----
var $Error = "";
var $ora_no_next_fetch=false;
+ var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore error, but spit a warning)
***************
*** 38,46 ****
var $revision = "1.2";
- var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
-
/* public: constructor */
! function DB_Sql($query = "") {
! $this->query($query);
}
--- 39,47 ----
var $revision = "1.2";
/* public: constructor */
! function DB_Oracle($query = "") {
! if($query) {
! $this->query($query);
! }
}
***************
*** 86,91 ****
}
if (!$this->Link_ID) {
! $this->halt("connect() Link-ID == false " .
! "($this->Link_ID), ora_plogon failed");
} else {
//echo "commit on<p>";
--- 87,91 ----
}
if (!$this->Link_ID) {
! $this->connect_failed();
} else {
//echo "commit on<p>";
***************
*** 98,101 ****
--- 98,106 ----
}
+ function connect_failed() {
+ $this->Halt_On_Error = "yes";
+ $this->halt("connect ($this->User, \$Password, $this->Database) failed");
+ }
+
## In order to increase the # of cursors per system/user go edit the
## init.ora file and increase the max_open_cursors parameter. Yours is on
***************
*** 400,415 ****
/* private: error handling */
function halt($msg) {
! if ($this->Halt_On_Error == "no")
return;
$this->haltmsg($msg);
! if ($this->Halt_On_Error != "report")
die("Session halted.");
}
function haltmsg($msg) {
! printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>Oracle Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
--- 405,420 ----
/* private: error handling */
function halt($msg) {
! if ("no" == $this->Halt_On_Error)
return;
$this->haltmsg($msg);
! if ("report" != $this->Halt_On_Error)
die("Session halted.");
}
function haltmsg($msg) {
! printf("<p><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>Oracle Error</b>: %s (%s)</p>\n",
$this->Errno,
$this->Error);
***************
*** 431,433 ****
--- 436,450 ----
}
}
+ $_php_major_version = substr(phpversion(), 0, 1);
+ if((4 > $_php_major_version) or !class_exists("DB_Sql"))
+ {
+ class DB_Sql extends DB_Oracle
+ {
+ function DB_Sql($query = "")
+ {
+ $this->DB_Oracle($query);
+ }
+ }
+ }
+ unset($_php_major_version);
?>
Index: db_pgsql.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_pgsql.inc,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** db_pgsql.inc 26 Aug 2002 08:27:43 -0000 1.9
--- db_pgsql.inc 23 Jul 2004 20:36:29 -0000 1.10
***************
*** 10,14 ****
*/
! class DB_Sql {
var $Host = "";
var $Database = "";
--- 10,14 ----
*/
! class DB_Pgsql {
var $Host = "";
var $Database = "";
***************
*** 27,30 ****
--- 27,31 ----
var $Error = "";
var $Debug = 0;
+ var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore error, but spit a warning)
var $Auto_Free = 0; # Set this to 1 for automatic pg_freeresult on
***************
*** 37,42 ****
/* public: constructor */
! function DB_Sql($query = "") {
$this->query($query);
}
--- 38,45 ----
/* public: constructor */
! function DB_Pgsql($query = "") {
! if($query) {
$this->query($query);
+ }
}
***************
*** 54,62 ****
}
if (!$this->Link_ID) {
! $this->halt("connect() failed.");
}
}
}
function query($Query_String) {
/* No empty queries, please, since PHP4 chokes on them. */
--- 57,70 ----
}
if (!$this->Link_ID) {
! $this->connect_failed();
}
}
}
+ function connect_failed() {
+ $this->Halt_On_Error = "yes";
+ $this->halt("connect ($this->Host" . (($this-Port) ? ":$this->Port" : "") . ", $this->User, \$Password, $this->Database) failed");
+ }
+
function query($Query_String) {
/* No empty queries, please, since PHP4 chokes on them. */
***************
*** 220,228 ****
function halt($msg) {
! printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>PostgreSQL Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
- die("Session halted.");
}
--- 228,245 ----
function halt($msg) {
! if ("no" == $this->Halt_On_Error)
! return;
!
! $this->haltmsg($msg);
!
! if ("report" != $this->Halt_On_Error)
! die("Session halted.");
! }
!
! function haltmsg($msg) {
! printf("<p><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>PostgreSQL Error</b>: %s (%s)</p>\n",
$this->Errno,
$this->Error);
}
***************
*** 240,242 ****
--- 257,271 ----
}
}
+ $_php_major_version = substr(phpversion(), 0, 1);
+ if((4 > $_php_major_version) or !class_exists("DB_Sql"))
+ {
+ class DB_Sql extends DB_Pgsql
+ {
+ function DB_Sql($query = "")
+ {
+ $this->DB_Pgsql($query);
+ }
+ }
+ }
+ unset($_php_major_version);
?>
Index: db_sybase.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_sybase.inc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** db_sybase.inc 14 Mar 2002 20:41:07 -0000 1.4
--- db_sybase.inc 23 Jul 2004 20:36:29 -0000 1.5
***************
*** 14,18 ****
*/
! class DB_Sql {
var $Host = "";
var $Database = "";
--- 14,18 ----
*/
! class DB_Sybase {
var $Host = "";
var $Database = "";
***************
*** 25,34 ****
var $Row;
var $Auto_Free = 0; ## Set this to 1 for automatic sybase_free_result()
var $PConnect = 0; ## Set to 1 to use persistent database connections
/* public: constructor */
! function DB_Sql($query = "") {
$this->query($query);
}
--- 25,38 ----
var $Row;
+ var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore error, but spit a warning)
+
var $Auto_Free = 0; ## Set this to 1 for automatic sybase_free_result()
var $PConnect = 0; ## Set to 1 to use persistent database connections
/* public: constructor */
! function DB_Sybase($query = "") {
! if($query) {
$this->query($query);
+ }
}
***************
*** 41,52 ****
}
if (!$this->Link_ID) {
! $this->halt("connect($this->Host, $this->User, \$Password) failed.");
}
if(!sybase_select_db($this->Database, $this->Link_ID)) {
! $this->halt("cannot use database ".$this->Database);
}
}
}
function query($Query_String) {
--- 45,61 ----
}
if (!$this->Link_ID) {
! $this->connect_failed("connect ($this->Host, $this->User, \$Password) failed");
}
if(!sybase_select_db($this->Database, $this->Link_ID)) {
! $this->connect_failed("cannot use database ".$this->Database);
}
}
}
+ function connect_failed($message) {
+ $this->Halt_On_Error = "yes";
+ $this->halt($message);
+ }
+
function query($Query_String) {
***************
*** 146,153 ****
function halt($msg) {
! printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>Sybase Error</b><br>\n");
! die("Session halted.");
}
}
?>
--- 155,183 ----
function halt($msg) {
! if ("no" == $this->Halt_On_Error)
! return;
!
! $this->haltmsg($msg);
!
! if ("report" != $this->Halt_On_Error)
! die("Session halted.");
! }
!
! function haltmsg($msg) {
! printf("<p><b>Database error:</b> %s<br>\n", $msg);
! printf("<b>Sybase Error</b></p>\n", $this->Error);
}
}
+ $_php_major_version = substr(phpversion(), 0, 1);
+ if((4 > $_php_major_version) or !class_exists("DB_Sql"))
+ {
+ class DB_Sql extends DB_Sybase
+ {
+ function DB_Sql($query = "")
+ {
+ $this->DB_Sybase($query);
+ }
+ }
+ }
+ unset($_php_major_version);
?>
Index: template.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/template.inc,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** template.inc 21 Apr 2004 10:51:09 -0000 1.14
--- template.inc 23 Jul 2004 20:36:29 -0000 1.15
***************
*** 100,103 ****
--- 100,115 ----
/**
+ * Determines the regular expression used to find unknown variable tags.
+ * "loose" = traditional match all curly braces with no whitespace between
+ * "strict" = adopts PHP's variable naming rules
+ * ("loose" has a nasty habit of deleting JavaScript RegEx components)
+ * (should future major version releases of PHPLib default this "strict"?)
+ *
+ * @var string
+ * @access public
+ */
+ var $unknown_regexp = "loose";
+
+ /**
* The base directory from which template files are loaded.
*
***************
*** 209,212 ****
--- 221,227 ----
*/
function set_root($root) {
+ if(ereg('/$', $root)) {
+ $root = substr($root, 0, -1);
+ }
if ($this->debug & 4) {
echo "<p><b>set_root:</b> root = $root</p>\n";
***************
*** 738,742 ****
}
! preg_match_all("/{([^ \t\r\n}]+)}/", $this->get_var($varname), $m);
$m = $m[1];
if (!is_array($m)) {
--- 753,760 ----
}
! preg_match_all(
! (("loose" == $this->unknown_regexp) ? "/{([^ \t\r\n}]+)}/" : "/{([_a-zA-Z]\\w+)}/"),
! $this->get_var($varname),
! $m);
$m = $m[1];
if (!is_array($m)) {
***************
*** 781,789 ****
case "remove":
! $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str);
break;
case "comment":
! $str = preg_replace('/{([^ \t\r\n}]+)}/', "<!-- Template variable \\1 undefined -->", $str);
break;
}
--- 799,813 ----
case "remove":
! $str = preg_replace(
! (("loose" == $this->unknown_regexp) ? "/{([^ \t\r\n}]+)}/" : "/{([_a-zA-Z]\\w+)}/"),
! "",
! $str);
break;
case "comment":
! $str = preg_replace(
! (("loose" == $this->unknown_regexp) ? "/{([^ \t\r\n}]+)}/" : "/{([_a-zA-Z]\\w+)}/"),
! "<!-- Template variable \\1 undefined -->",
! $str);
break;
}
|