Re: Addition to DB/common.php ?
| From: | Stig S. Bakken | Date: | Fri, 02 Feb 2001 22:34:45 +0000 |
| Subject: | Re: Addition to DB/common.php ? | ||
| References: | 1 | Groups: | php.pear |
| Request: | Send a blank email to php-pear+get-1253@lists.php.net to get a copy of this message | ||
Take a look at DB/storage.php. This class is supposed to let you make
an object representing a row of a table and manipulate the object and
have changes done in the database transparently.
Example of use (from pearweb/include/pear-prepend.php):
class Author extends DB_storage
{
function Author(&$dbh, $handle = false) {
$this->DB_storage("authors", "handle", &$dbh);
if ($handle) {
$this->setup($handle);
}
}
}
$dbh = DB::connect("mysql://user:pw@localhost/mydb");
$authorObject =& new Author($dbh, $mynick);
- Stig
Joao Prado Maia wrote:
>
> I was doing some coding this past weekend on some personal projects and I
> ended up creating a wrapper to PEAR's DB.php for some functions that I
> usually like to use.
>
> I usually create several functions to insert / update / delete records by
> passing $table_name, $fields (associative array) and $conditions if
> appropriate.
>
> Everyone is probably going to beat me up for this, but can I add these
> functions to DB/common.php ? I'm not sure if they would be categorized as
> pure 'bloat', but I figured I should ask anyway.
>
> I could also create this as a subclass for DB.php and go from there, but
> it would be kinda too much abstraction and sub-layers of functions,
> wouldn't it ?
>
> Joao
>
> --
> João Prado Maia <jpm@phpbrasil.com>
> http://phpbrasil.com - php com um jeitinho brasileiro
>
> --
> PHP Extension and Add-on Repository (PEAR) mailing list.
> Documentation can be found at http://pear.php.net/doc/pear.html
> To unsubscribe, e-mail: php-pear-unsubscribe@lists.php.net from the
> mail address you subscribed with.