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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:58:04+00:00 2026-05-23T11:58:04+00:00

I am appreciated if someone shows a complete example on how to use findByAttributes

  • 0

I am appreciated if someone shows a complete example on how to use findByAttributes in Yii framework.

Official doc @ http://www.yiiframework.com/doc/api/1.1/CActiveRecord#findByAttributes-detail

public CActiveRecord findByAttributes(array $attributes, mixed $condition='', array $params=array ( ))

I know how to use $attributes. I do not see a good reason to use $condition and $params in findByAttributes.

Please tell me under what scenario, you use them in findByAttributes.

Thank you

  • 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-23T11:58:05+00:00Added an answer on May 23, 2026 at 11:58 am

    It seems like it was included to match similar function in other frameworks and best used when your query is mostly an array of column names like array('dept_id'=>2,'active'=>'y') — there might be times in your program where it’s easier to pass an array in this format rather than having to re-write them into conditions. You might want to add additional conditions in the $condition paramater or ones that $attributes may not support like project_name LIKE "foo%".

    $params are used here like other query types, to bind condition values to column types for filtering.

    see: http://www.yiiframework.com/doc/guide/1.1/en/database.ar#reading-record

    Info: When a query condition is about
    matching some columns with the
    specified values, we can use
    findByAttributes(). We let the
    $attributes parameters be an array of
    the values indexed by the column
    names. In some frameworks, this task
    can be achieved by calling methods
    like findByNameAndTitle. Although this
    approach looks attractive, it often
    causes confusion, conflict and issues
    like case-sensitivity of column names.

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

Sidebar

Related Questions

http://support.microsoft.com/kb/213930 shows How to Create a Bell Curve Chart. I need to automate this
I really appreciate if someone can help me with using how to use shape
I would appreciate if someone could direct me to a website that shows how
I am a complete newbie when it comes to JS. I actually paid someone
I just cannot get this to work, would appreciate if someone can help. So
I am a Java beginner and I would appreciate it if someone here can
I don't understand what's happening here. If someone could explain, I would appreciate it.
Any help would be appreciated, I'm trying to convert the code below to C#,
Any help is appreciated. When using cfimage to generate a captcha, we keep his
Any help most appreciated, this is driving me insane. I'm doing exactly what I

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.