RE: [PEAR] dataobjects newbie question
| From: | Denis Gerasimov | Date: | Mon, 18 Oct 2004 10:00:18 +0000 |
| Subject: | RE: [PEAR] dataobjects newbie question | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14944@lists.php.net to get a copy of this message | ||
Hello,
I think that would be also a good suggestion (simplified example):
class AdvancedDataObject extends DB_DataObject
{
function fetchArray($strFormat = '%s')
{
return $this->fetch() ? $this->toArray($strFormat) : false;
}
function fetchAllArray($strFormat = '%s')
{
$arrDataset = array();
while ($this->fetch()) {
$arrDataset[] = $this->toArray($strFormat);
}
return $arrDataset;
}
}
(We don't call find() since original fetch() method doesn't, so call find()
manually before pls)
At least we don't need to call toArray() every time or write a loop for
fetching all records to one recordset-like array.
Or is there more straight ways for doing all of these? :-)
Best regards, Denis Gerasimov
Outsourcing Services Manager,
VEKOS, Ltd.
www.vekos.ru
> -----Original Message-----
> From: Justin Patrin [mailto:papercrane@gmail.com]
> Sent: Monday, October 18, 2004 10:38 AM
> To: Alexander Petri
> Cc: pear-general@lists.php.net
> Subject: Re: [PEAR] dataobjects newbie question
>
> On Sun, 17 Oct 2004 11:28:33 +0200, Alexander Petri <alex.petri@gmx.de>
> wrote:
> > Hi!
> > how can i select the whole table with dataobject...
> > i chose this way:
> >
> > $firma = DB_DataObject::factory('crm_firmen');
> > $firma->query("SELECT * FROM {$firma->__table} ");
> > while ($firma->fetch()) {
> > $rs[]= $firma->toArray();
> > }
> >
> > but isnt there a better way to selectAll
> > isnt there a method to do this?
> >
>
> $firma = DB_DataObject::factory('crm_firmen');
> if ($firma->find()) {
> while ($firma->fetch()) {
> $rs[]= clone($firma);
> }
> }
>
> --
> paperCrane --Justin Patrin--
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php