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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:57:28+00:00 2026-06-08T02:57:28+00:00

I often face this problem.. Lets say ..In blog application, I need to email

  • 0

I often face this problem..

Lets say ..In blog application, I need to email all the active users..

What I do is write findAll on users with some conditions of their last login being greater than some value..and get all the User objects…Then run a foreach through all the user model objects and store emails in a array, then use the array..

I other words what is happening in back-end is I am loading whole model, while I only need barely0.5% of that information, and then running a dirty code to get values in in array, and then process with it..

Isn’t it quite bad in performance and dirty code..

Now other approach I can think of is using commandBuilder and write query and then run same dirty code to get values in array..one problem of performance resolved..but as people say writing sql in mvc frameworks, is not a really good idea..

What I really want…some similar functions which give me column values in array if it is a single column, or array with column name as index if multiple columns..

So what I am thinkin of doing is implement it by extending ActiveRecord or something similar, what I want to check is if some one has already implemented something similar, or have some ideas for it..:)

  • 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-08T02:57:29+00:00Added an answer on June 8, 2026 at 2:57 am

    I created the behavior as I said, the way it works is:

    $active_users_emails = User::model()->findColumn('email', 'active = 1');
    
    **returns array('rajat@gmail.com','rajatsinghal@gmail.com')..**
    

    Now one doesn’t need to go through all activerecords and collect
    column in array, then proceed, and also bear weight of loading whole
    column..

    You can find the extension on git ..https://github.com/rajatsinghal/CAdvancedArFindBehavior

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

Sidebar

Related Questions

I often face this problem with git: I clone a git repo of some
I often face the problem of wanting to add additional methods to classes I
Often times I write some SQL like this: string sql = @ -- Multi-line
Often I face the problem of mapping the parameter space of one API onto
Problem: I often need to refer a row to a column (using =Cell). When
I face this often. Suppose I have killed a buffer. And then I go
A problem that I often face with Hibernate is having a list (call it
Often, I found OutOfMemoryException on IBM Websphere Application Server. I think this exception occur
I've often had this problem in the past and to this date haven't found
In process of developing I often face with the next problem: if some method

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.