Re: cvs: pear /DB/DB common.php
| From: | Tomas V.V.Cox | Date: | Tue, 11 Jun 2002 11:28:34 +0000 |
| Subject: | Re: cvs: pear /DB/DB common.php | ||
| References: | 1 2 3 | Groups: | php.pear.cvs |
| Request: | Send a blank email to pear-cvs+get-4547@lists.php.net to get a copy of this message | ||
MARTY Fabien wrote:
>
> (Fabien)
> >> Modified files:
> >> /pear/DB/DB common.php
> >> Log:
> >> Add of autoPrepare()
>
> (Tomas)
> > Umm, I'm asking my self why not directly execute the query too?
> > return $this->query($sql, array_values($array));
> > would do the trick. btw the method could become something like
> > autoExecute or buildExecute.
>
> I have thought about that. I write autoPrepare() because of flexibility. If
> you want to use executeMultiple() for example with another array !
>
> But I agree with you. In most cases, you have to write two lines ! With
> autoExecute(), one line is enough !
>
> So, I propose to keep autoPrepare() (for flexibility reasons) and to add
> autoExecute(). To avoid copy/paste of the code, I could make a private method
> to build the sql query used by autoPrepare() and autoExecute().
>
> I let you take the final decision :-)) For me, there are three choices :
> - autoPrepare() only (now)
> - autoPrepare() and autoExecute() (with a little private query builder)
> - autoExecute() only
>
How sounds:
- buildManipSQL($table, $table_fields, $mode, $where = false)
- autoPrepare($table, $table_fields, $mode, $where = false)
- autoExecute($table, $fields_values, $mode, $where = false)
$table_fields -> ordered array
$fields_values -> assoc array
Why you pass an assoc to the actual autoPrepare()? I guess that normally
one has the table names in one side and the values in another.
Tomas V.V.Cox