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

  • Home
  • SEARCH
  • 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 must develop a simple web application to produce reports. I have a single
Im using LinqDataSource like that: <asp:LinqDataSource ID=LinqDataSource3 runat=server OnSelecting=LinqDataSource3_OnSelecting> </asp:LinqDataSource> And I have ASPxGridView
I've got a simple table Logins with two columns: username (nvarchar) logged (datetime) It's
I'm new to Linq. I have searched and searched the web for a solution,
I have worked with MS CRM. There we can design our custom entity graphically
I have small problem when trying to create many-to-many link in doctrine. I have
I think my question is best explained via an example: Suppose I want to
I have recently starting porting a small app of mine to Facebook as a
What I'm trying to achieve must be simple but I just can't get it
I've been banging my head on this one for a while and I figured

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.