Date: 06/13/01
- Next message: Lazaro Ferreira: "[phplib] Looking for shopping cart applications based on PHPLIB core classes"
- Previous message: Brian Popp: "RE: [phplib] Cookie Not Being Set"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi all!
I've been using a few extensions to the db stuff that make using the
code alot easier. (for me)
The core of the change(s) is GetArray() - which returns the results of
the query in an array that can be easily walked thru. To make this work
properly, a change is made to the db_sql.inc starting on line 79, to
read:
function next_record() {
$this->Record = <email protected>($this->Query_ID, $this->Row++,
PGSQL_ASSOC);
$this->Error = pg_ErrorMessage($this->Link_ID);
$this->Errno = ($this->Error == "")?0:1;
$stat = is_array($this->Record);
if (!$stat && $this->Auto_Free) {
pg_freeresult($this->Query_ID);
$this->Query_ID = 0;
}
return $stat;
}
The change is "PGSQL_ASSOC".
With the exception of method insert, this should run unmodified on any
database, though (as is obvious) I use PostgreSQL.
-Ben
EXTENSIONS:
class local_db extends db_sql {
var $classname ='local_db';
var $Database ='test';
var $User ='test_account';
var $Password ='12345';
Function Local_DB($Database, $User, $Password='') {
if (strlen($Database)<1)
return false;
if (strlen($User)<=1)
return false;
$this->Database=$Database;
$this->User=$User;
$this->Password=$Password;
return true;
}
Function GetArray($sql){
$result=$this->query($sql);
while ($row=$this->Next_Record())
$return[]=$this->Record;
if (!$return)
$return=$this->affected_rows();
return $return;
}
Function Insert($table, $sql) {
$result=$this->query($sql);
$oid=pg_getlastoid($result);
if ($oid<1)
return 0;
$sql="SELECT ID FROM $table WHERE OID=$oid";
if (!$result=$this->GetArray($sql))
return false;
else return $result[0][id];
}
} // END OF CLASS LOCAL_DB
-- "Life is short. Live it!"--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>
- Next message: Lazaro Ferreira: "[phplib] Looking for shopping cart applications based on PHPLIB core classes"
- Previous message: Brian Popp: "RE: [phplib] Cookie Not Being Set"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

