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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:26:09+00:00 2026-05-20T16:26:09+00:00

I have one simple users table, and I want to find all users where

  • 0

I have one simple users table, and I want to find all users where email_notifications = 1.

Logic dictates that the following should work:

class Controller_Test extends Controller {

    public function action_index()
    {
        $user = ORM::factory('user');
        $user = $user->where('email_notifications', '=', 1);
        $total = $user->count_all();
        $users = $user->find_all();

        echo $total." records found.<br/>";

        foreach ($users as $v)
        {
            echo $v->id;
            echo $v->first_name;
            echo $v->last_name;
            echo $v->email;
        }
    }
}

However, what’s happening is that I am getting ALL of my users back from the DB, not just the ones with email_notifications turned on. The funny thing is, the $total value returned is the accurate number result of this query.

I am so stumped, I have no idea what the problem is here. If anyone could shed some light, I’d really appreciate it.

Thanks,
Brian

  • 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-05-20T16:26:10+00:00Added an answer on May 20, 2026 at 4:26 pm

    Calling count_all() will reset your model conditions. Try to use reset(FALSE) to avoid this:

        $user = ORM::factory('user');
        $user = $user->where('email_notifications', '=', 1);
        $user->reset(FALSE); 
        $total = $user->count_all();
        $users = $user->find_all();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know zero javascript, and have one simple task: Find all text in the
I have one simple app that suppose to get information from user and send
This should be a simple one: I have an observableArray object called To in
this time i have a simple question: I have one table, related with himself
This will hopefully be a simple one: I have a div I want to
I got a simple problem in SQLAlchemy. I have one model in a table,
I've got a simple table that allows users to enter 2 numbers, and then
I need to get a simple count of users that have >5 accounts tagged
I have a simple one-to-many relationship. I would like to select rows from the
A simple example: Let's say I have one alias being sourced somewhere as: alias

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.