Re: [PHP-PEAR] Addition to DB/common.php ?
[email protected] ("Stig S. Bakken")
| Newsgroups | php.pear |
|---|---|
| Organization | Fast Search & Transfer |
| Message-ID | <[email protected]> |
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 <[email protected]>
> 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: [email protected] from the
> mail address you subscribed with.