Re: DB_Storage examples

From: Date: Wed, 13 Mar 2002 09:09:57 +0000
Subject: Re: DB_Storage examples
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-962@lists.php.net to get a copy of this message
On Wed, 2002-03-13 at 08:40, Tobias Nix wrote: > hello, > > can somebody give me an usage example of DB_Storage? > sometimes ago wolfram wrote a mail about this, > but i can't find it again. $dbh = DB::connect("mysql://user:pw@server/database"); // this gives you a DB_Storage object using the table "mytable" // and the "id" column as a key $obj = new DB_Storage("mytable", "id", $dbh); // this reads data from the row where id = 42 $obj->setup(42); This: $obj->set('foo', 'magic'); $obj->store(); is then equivalent to: UPDATE mytable SET foo = 'magic' WHERE id = 42; You don't have to call store() explicitly, it will be called at the end of the request if necessary. - Stig

« previous php.pear.general (#962) next »