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 7823261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:10:57+00:00 2026-06-02T08:10:57+00:00

I need to run a query in zend frawork. The query is as given

  • 0

I need to run a query in zend frawork. The query is as given below.

select * from users where role_id in (3,5) and emailID not in ('abc@abc.com', 'cba@cba.com');

I am passing the string

$whereString = role_id in (3,5) and emailID not in ('abc@abc.com', 'cba@cba.com');

to

$this->fetchList($whereString) // where $this is object of users

But fetchList() function executes only the first part i.e role_id in (3,5)

but not the second part i.e emailID not in ('abc@abc.com', 'cba@cba.com');

The result from fetchList() contains ‘abc@abc.com’ and ‘cba@cba.com’

fetchList() is:

    public function fetchList($where=null, $order=null, $count=null, $offset=null)
        {
                $resultSet = $this->getDbTable()->fetchAll($where, $order, $count, $offset);
                $entries   = array();
                foreach ($resultSet as $row)
                {
                        $entry = new Application_Model_Users();
                        $entry->setId($row->id)
                              ->setName($row->name)
                              ->setEmail($row->email)
                        $entries[] = $entry;
                }
                return $entries;
        }

fetchAll():

   /**
     * Fetches all rows.
     *
     * Honors the Zend_Db_Adapter fetch mode.
     *
     * @param string|array|Zend_Db_Table_Select $where  OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object.
     * @param string|array                      $order  OPTIONAL An SQL ORDER clause.
     * @param int                               $count  OPTIONAL An SQL LIMIT count.
     * @param int                               $offset OPTIONAL An SQL LIMIT offset.
     * @return Zend_Db_Table_Rowset_Abstract The row results per the Zend_Db_Adapter fetch mode.
     */
    public function fetchAll($where = null, $order = null, $count = null, $offset = null)
    {
        if (!($where instanceof Zend_Db_Table_Select)) {
            $select = $this->select();

            if ($where !== null) {
                $this->_where($select, $where);
            }

            if ($order !== null) {
                $this->_order($select, $order);
            }

            if ($count !== null || $offset !== null) {
                $select->limit($count, $offset);
            }

        } else {
            $select = $where;
        }
        print_r($select);
        $rows = $this->_fetch($select);

        $data  = array(
            'table'    => $this,
            'data'     => $rows,
            'readOnly' => $select->isReadOnly(),
            'rowClass' => $this->getRowClass(),
            'stored'   => true
        );

        $rowsetClass = $this->getRowsetClass();
        if (!class_exists($rowsetClass)) {
            require_once 'Zend/Loader.php';
            Zend_Loader::loadClass($rowsetClass);
        }
        return new $rowsetClass($data);
    }

Any body knows what wrong did I do.

  • 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-02T08:10:58+00:00Added an answer on June 2, 2026 at 8:10 am

    I’m going out on a bit of limb, because I’m not sure. This feels like it might be a quote issue. Maybe try passing your query string like:

    //use Zend_Db_Statement to process raw SQL.
    
    //get default adapter
    $db = Zend_Db_Table::getDefaultAdapter();
    //write SQL statement
    $sql = "select * from users where role_id in (3,5) and emailID not in ('abc@abc.com', 'cba@cba.com')";
    //assuming MySql as DB instantiate object
    $stmt = new Zend_Db_Statement_Mysqli($db, $sql);
    //Execute SQL Statement accepts optional parameter for array() of values to be bound
    $stmt->execute();
    

    or you might like to build the query using the select() object:

    //get default adapter
    $db = Zend_Db_Table::getDefaultAdapter();
    //instantiate the select() object
    $select = new Zend_Db_Select($db);
    $select->from('users');
    //two where will build an AND query use $select->orWhere() to build an OR query 
    $select->where('role_id in (3,5)');
    $select->where("emailID not in ('abc@abc.com', 'cba@cba.com')");
    $result = $model->fetchList($select);
    

    and it might work if $whereString were a valid PHP string, beacuse fetchAll() accepts a string or an instance of Zend_Db_Select:

    $whereString = “role_id in (3,5) and emailID not in (‘abc@abc.com’, ‘cba@cba.com’)”;

    Hope this helps some… I took a shot.

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

Sidebar

Related Questions

I need to run a query like: SELECT p.id, p.name, (SELECT name FROM sites
I need to run a query that returns a list of users, along with
I am getting query from database. Using that query I need to run that
I have 2 tables from which i need to run a query to display
I need to run a JOIN query on a solr index. I've got two
I need to be able to run an Oracle query which goes to insert
I want to run a sql query on a specific schedule (weekly) and need
I need run ts:reindex when smth add in model or destroy from model. How
I need to run an external application from within my Java code. I can
I need to run query called MyQuery that I have in Access that makes

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.