> If I were you I wouldn't change the Zend source code. But write your own
> class en overwrite this select function. Something like this:
>
> class MyTableClass_Db_Table extends Zend_Db_Table_Abstract {
> public function select($columns) {
> ...
> }
> }
>
> class DestinationModel extends MyTableClass_Db_Table
> {
> ...
> }
>
>
> Ionut Gabriel Stan-2 wrote:
>> Hello,
>>
>> I've just begun exploring Zend_Db_Table_Abstract and found myself
>> passing an array of fields to its select() method so that a final DB
>> result set would only include the specified fields:
>>
>> public function getByDestination($continentId, $countryId, $cityId)
>> {
>> return $this->fetchAll(
>> $this->select(array('name'))
>> ->where('continent_id = ?', $continentId)
>> ->where('country_id = ?', $countryId)
>> ->where('city_id = ?', $cityId)
>> ->order('name ASC')
>> ->limit(10)
>> );
>> }
>>
>> Unfortunately this isn't working right now so I tried modifying the
>> source of Zend_Db_Table_Abstract and it turns out that what I did works
>> quite well for me. Here's what I did:
>>
>> public function select($columns)
>> {
>> require_once 'Zend/Db/Table/Select.php';
>> $select = new Zend_Db_Table_Select($this);
>> $select->from($this->_name, $columns);
>> return $select;
>> }
>>
>> Now, as I said, these are my first lines of code using this ZF component
>> so I'd like to hear your opinion about it or maybe existing alternatives
>> to what I did.
>>
>>
>> Cheers,
>> Ionut
>>
>>
>
>
> -----
> visit my website at http://www.phpscriptor.com/ http://www.phpscriptor.com/
Absolutely. That's the way to go. What I did was just for a quick check.
The main reason for my previous email is that I think this feature
should already be in the standard version of Zend_Db_Table_Abstract.
没有评论:
发表评论