Date: 07/23/00
- Next message: ssilk: "[phplib-dev] cvs commit"
- Previous message: ssilk: "[phplib-dev] cvs commit"
- Next in thread: ssilk: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: ssilk
Date: Mon Jul 24 03:34:24 2000
Modified files:
php-lib/php/db/mysql/db_sql.inc
Log message:
some beautyfiying and perhaps speedup...
Index: php-lib/php/db/mysql/db_sql.inc
diff -u php-lib/php/db/mysql/db_sql.inc:1.2 php-lib/php/db/mysql/db_sql.inc:1.3
--- php-lib/php/db/mysql/db_sql.inc:1.2 Mon Jun 5 10:26:55 2000
+++ php-lib/php/db/mysql/db_sql.inc Mon Jul 24 03:33:52 2000
@@ -5,36 +5,36 @@
* Copyright (c) 1998-2000 NetUSE GmbH
* Boris Erdmann, Kristian Koehntopp
*
- * $Id: db_sql.inc,v 1.2 2000/06/05 08:26:55 kk Exp $
+ * $Id: db_sql.inc,v 1.3 2000/07/24 01:33:52 ssilk Exp $
*
*/
class DB_MySQL_Sql extends DB_Generic_Sql {
/* public: connection parameters */
- var $Host = "";
- var $Database = "";
- var $User = "";
- var $Password = "";
+ var $Host = '';
+ var $Database = '';
+ var $User = '';
+ var $Password = '';
/* public: this is an api revision, not a CVS revision. */
- var $type = "mysql";
- var $revision = "1.3";
+ var $type = 'mysql';
+ var $revision = '1.3';
/* public: constructor */
- function DB_MySQL_Sql($query = "") {
+ function DB_MySQL_Sql($query = '') {
$this->query($query);
}
/* public: connection management */
- function connect($Database = "", $Host = "", $User = "", $Password = "") {
+ function connect($Database = '', $Host = '', $User = '', $Password = '') {
/* Handle defaults */
- if ("" == $Database)
+ if ('' == $Database)
$Database = $this->Database;
- if ("" == $Host)
+ if ('' == $Host)
$Host = $this->Host;
- if ("" == $User)
+ if ('' == $User)
$User = $this->User;
- if ("" == $Password)
+ if ('' == $Password)
$Password = $this->Password;
/* establish connection, select database */
@@ -47,7 +47,7 @@
}
if (! <email protected>($Database,$this->Link_ID)) {
- $this->halt("cannot use database ".$Database);
+ $this->halt('cannot use database '.$Database);
return 0;
}
}
@@ -63,7 +63,7 @@
/* public: perform a query */
function query($Query_String) {
- if ($Query_String == "")
+ if ($Query_String == '')
return 0;
$this->Query_Str = $Query_String;
@@ -77,13 +77,13 @@
}
if ($this->Debug)
- printf("Debug: query = %s<br>\n", $Query_String);
+ printf('Debug: query = %s<br>\n', $Query_String);
$this->Query_ID = <email protected>($Query_String,$this->Link_ID);
$this->Row = 0;
$this->check_error();
if (!$this->Query_ID) {
- $this->halt("Query failed.");
+ $this->halt('Query failed.');
}
# Will return nada if it fails. That's fine.
@@ -93,7 +93,7 @@
/* public: walk result set */
function next_record() {
if (!$this->Query_ID) {
- $this->halt("next_record called with no query pending.");
+ $this->halt('next_record called with no query pending.');
return 0;
}
@@ -114,7 +114,7 @@
if ($status)
$this->Row = $pos;
else {
- $this->halt("seek($pos) failed: result has ".$this->num_rows()." rows.");
+ $this->halt('seek($pos) failed: result has '.$this->num_rows().' rows.');
/* half assed attempt to save the day,
* but do not consider this documented or even
@@ -129,13 +129,13 @@
}
/* public: table locking */
- function lock($table, $mode="write") {
+ function lock($table, $mode='write') {
$this->connect();
- $query="lock tables ";
+ $query='lock tables ';
if (is_array($table)) {
while (list($key,$value)=each($table)) {
- if ($key=="read" && $key!=0) {
+ if ($key=='read' && $key!=0) {
$query.="$value read, ";
} else {
$query.="$value $mode, ";
@@ -156,9 +156,9 @@
function unlock() {
$this->connect();
- $res = <email protected>("unlock tables");
+ $res = <email protected>('unlock tables');
if (!$res) {
- $this->halt("unlock() failed.");
+ $this->halt('unlock() failed.');
return 0;
}
return $res;
@@ -183,7 +183,7 @@
if ($this->lock($this->Seq_Table)) {
/* get sequence number (locked) and increment */
- $q = sprintf("select p_nextid from %s where p_seq_name = '%s'",
+ $q = sprintf('select p_nextid from %s where p_seq_name = '%s'',
$this->Seq_Table,
$seq_name);
$id = <email protected>($q, $this->Link_ID);
@@ -192,30 +192,30 @@
/* No current value, make one */
if (!is_array($res)) {
$currentid = 0;
- $q = sprintf("insert into %s ( p_seq_name, p_nextid ) values('%s', %s)",
+ $q = sprintf('insert into %s ( p_seq_name, p_nextid ) values('%s', %s)',
$this->Seq_Table,
$seq_name,
$currentid);
$id = <email protected>($q, $this->Link_ID);
} else {
- $currentid = $res["p_nextid"];
+ $currentid = $res['p_nextid'];
}
$nextid = $currentid + 1;
- $q = sprintf("update %s set p_nextid = '%s' where p_seq_name = '%s'",
+ $q = sprintf('update %s set p_nextid = '%s' where p_seq_name = '%s'',
$this->Seq_Table,
$nextid,
$seq_name);
$id = <email protected>($q, $this->Link_ID);
$this->unlock();
} else {
- $this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
+ $this->halt('cannot lock '.$this->Seq_Table.' - has it been created?');
return 0;
}
return $nextid;
}
/* public: return table metadata */
- function metadata($table = "", $full = false) {
+ function metadata($table = '', $full = false) {
$count = 0;
$id = 0;
$res = array();
@@ -227,23 +227,23 @@
*
* - full is false (default):
* $result[]:
- * [0]["table"] table name
- * [0]["name"] field name
- * [0]["type"] field type
- * [0]["len"] field length
- * [0]["flags"] field flags
+ * [0]['table'] table name
+ * [0]['name'] field name
+ * [0]['type'] field type
+ * [0]['len'] field length
+ * [0]['flags'] field flags
*
* - full is true (was mainly introduced for the Query-class)
* $result[]:
- * ["num_fields"] number of metadata records
- * [0]["table"] table name
- * [0]["name"] field name
- * [0]["type"] field type
- * [0]["len"] field length
- * [0]["flags"] field flags
- * [0]["php_type"] the correspondig PHP-type
- * [0]["php_subtype"] the subtype of PHP-type
- * ["meta"][field name] index-num of field named "field name"
+ * ['num_fields'] number of metadata records
+ * [0]['table'] table name
+ * [0]['name'] field name
+ * [0]['type'] field type
+ * [0]['len'] field length
+ * [0]['flags'] field flags
+ * [0]['php_type'] the correspondig PHP-type
+ * [0]['php_subtype'] the subtype of PHP-type
+ * ['meta'][field name] index-num of field named 'field name'
* This could used, if you have the name, but no index-num - very fast
* [unique] = field names which have an unique key, separated by space
*/
@@ -254,13 +254,13 @@
$this->connect();
$id = <email protected>($this->Database, $table);
if (!$id) {
- $this->halt("Metadata query failed.");
+ $this->halt('Metadata query failed.');
return false;
}
} else {
$id = $this->Query_ID;
if (!$id) {
- $this->halt("No query specified.");
+ $this->halt('No query specified.');
return false;
}
}
@@ -270,56 +270,56 @@
// made this IF due to performance (one if is faster than $count if's)
if (!$full) {
for ($i=0; $i<$count; $i++) {
- $res[$i]["table"] = <email protected> ($id, $i);
- $res[$i]["name"] = <email protected> ($id, $i);
- $res[$i]["type"] = <email protected> ($id, $i);
- $res[$i]["len"] = <email protected> ($id, $i);
- $res[$i]["flags"] = <email protected> ($id, $i);
+ $res[$i]['table'] = <email protected> ($id, $i);
+ $res[$i]['name'] = <email protected> ($id, $i);
+ $res[$i]['type'] = <email protected> ($id, $i);
+ $res[$i]['len'] = <email protected> ($id, $i);
+ $res[$i]['flags'] = <email protected> ($id, $i);
}
} else { // full
$uniq=ARRAY();
- $res["num_fields"]= $count;
+ $res['num_fields']= $count;
for ($i=0; $i<$count; $i++) {
- $res[$i]["table"] = <email protected> ($id, $i);
- $res[$i]["name"] = <email protected> ($id, $i);
- $res[$i]["type"] = <email protected> ($id, $i);
- $res[$i]["len"] = <email protected> ($id, $i);
- $res[$i]["flags"] = <email protected> ($id, $i);
- $res["meta"][$res[$i]["name"]] = $i;
- switch ($res[$i]["type"]) {
- case "var string":
- case "string" :
- case "char" :
- $res[$i][php_type]="string";
- $res[$i][php_subtype]="";
+ $res[$i]['table'] = <email protected> ($id, $i);
+ $res[$i]['name'] = <email protected> ($id, $i);
+ $res[$i]['type'] = <email protected> ($id, $i);
+ $res[$i]['len'] = <email protected> ($id, $i);
+ $res[$i]['flags'] = <email protected> ($id, $i);
+ $res['meta'][$res[$i]['name']] = $i;
+ switch ($res[$i]['type']) {
+ case 'var string':
+ case 'string' :
+ case 'char' :
+ $res[$i]['php_type']='string';
+ $res[$i]['php_subtype']='';
break;
- case "timestamp" :
- case "datetime" :
- case "date" :
- case "time" :
- $res[$i][php_type]="string";
- $res[$i][php_subtype]="date";
+ case 'timestamp' :
+ case 'datetime' :
+ case 'date' :
+ case 'time' :
+ $res[$i]['php_type']='string';
+ $res[$i]['php_subtype']='date';
break;
- case "blob" :
- $res[$i][php_type]="string";
- $res[$i][php_subtype]="blob";
+ case 'blob' :
+ $res[$i]['php_type']='string';
+ $res[$i]['php_subtype']='blob';
break;
- case "real" :
- $res[$i][php_type]="double";
- $res[$i][php_subtype]="";
+ case 'real' :
+ $res[$i]['php_type']='double';
+ $res[$i]['php_subtype']='';
break;
- case "long" :
+ case 'long' :
default :
- $res[$i][php_type]="int";
- $res[$i][php_subtype]="";
+ $res[$i]['php_type']='int';
+ $res[$i]['php_subtype']='';
break;
}
- if ( ereg("(unique_key|primary_key)",$res[$i]["flags"]) ) {
- $uniq[]=$res[$i]["name"];
+ if ( ereg('(unique_key|primary_key)',$res[$i]['flags']) ) {
+ $uniq[]=$res[$i]['name'];
}
}
- $res["unique"]=join(" ",$uniq);
+ $res['unique']=join(' ',$uniq);
}
// free the result only if we were called on a table
@@ -331,12 +331,12 @@
/* public: find available table names */
function table_names() {
$this->connect();
- $h = <email protected>("show tables", $this->Link_ID);
+ $h = <email protected>('show tables', $this->Link_ID);
$i = 0;
while ($info = <email protected>($this->Query_ID)) {
- $return[$i]["table_name"]= $info[0];
- $return[$i]["tablespace_name"]=$this->Database;
- $return[$i]["database"]=$this->Database;
+ $return[$i]['table_name']= $info[0];
+ $return[$i]['tablespace_name']=$this->Database;
+ $return[$i]['database']=$this->Database;
$i++;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
For additional commands, e-mail: phplib-dev-help <email protected>
- Next message: ssilk: "[phplib-dev] cvs commit"
- Previous message: ssilk: "[phplib-dev] cvs commit"
- Next in thread: ssilk: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

