Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8004095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:49:34+00:00 2026-06-04T16:49:34+00:00

i have a fetchAll function in zend: public function fetchAll($where = 1, $order =

  • 0

i have a fetchAll function in zend:

public function fetchAll($where = 1, $order = null, $limit = null, $group = null, array $fields = null)
{
    $where = (null == $where) ? 1 : $where;


    $fields = (!isset($fields)) ? '*' : $fields;

    $select = $this->db->select()
                       ->from("table", $fields)
                       ->where($where)
                       ->order($order)
                       ->group($group)
                       ->limit($limit, $offset);
    echo $select; exit;
    $result = $this->db->fetchAll($select);
    return $this->getResultObjects($result);
}

and i can call this function $this->fetchAll('field = 1', null, 10);

i can $order to null and the query will work just fine but not the $group for some reason.

How can i make it so that the group is optional and goes in only if i sat it to something?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:49:35+00:00Added an answer on June 4, 2026 at 4:49 pm

    The methods are chained so you can split it up:

    $select = $this->db->select()
      ->from("table", $fields)
      ->where($where);
      ->order($order)
      ->limit($limit, $offset);
    
    if ($group) { 
      $select->group($group);
    }
    
    $result = $this->db->fetchAll($select);
    return $this->getResultObjects($result);
    

    Every method in the chain (from, where, order, etc) returns an instance of Zend_Db_Select. So every time you call one of those methods you can immediately follow it up with another method call from that same class.

    These code blocks are identical:

    // With chaining
    
    $select = $this->db->select()
      ->from("table", $fields)
      ->where($where);
      ->order($order)
      ->limit($limit, $offset);
    
    // No chaining
    
    $select = $this->db->select();
    $select = $select->from("table", $fields);
    $select = $select->where($where);
    $select = $select->order($order);
    $select = $select->limit($limit, $offset);
    

    You can see why chaining is preferred. Note: the assignment ($select =) is mostly superflous in the non-chain example, I only left it in to show the clunkyness.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query: public function checkUser($phone) { $sql = SELECT name FROM users
Providing that I have the following on: TeamGamesDao Class: public function listOfTeams() { $select
i have a function : def tong_thoigian (self,cr,uid,ids,context={}): obj=self.browse(cr,uid,ids,context=context)[0] cr.execute('''select name,giolam from x_giolam where
I have this function public function populate($id) { $pdo = new PDOConfig(); $sql =
I am developing a web application using zend framework. For select statements I have
I have to fetch all the files from a folder and i am using
Have a look at this picture alt text http://www.abbeylegal.com/downloads/2009-04-01/web%20part%20top%20line.jpg Does anyone know what css
Have someone tried out DeCAL in Delphi 2009? I'm thinking about upgrading from 2007,
have not tested on windows. but in ubuntu when u disconnect from the network,
I have a function in my model that I need to use multiple conditions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.