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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:03:36+00:00 2026-05-31T09:03:36+00:00

I’m reading the Yii blog tutorial . What does this code do foreach($models as

  • 0

I’m reading the Yii blog tutorial. What does this code do

foreach($models as $model)
    self::$_items[$type][$model->code]=$model->name;

in the loadItems static function. Where does [$model->code] and $model->name come from and what does this line of code 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-05-31T09:03:37+00:00Added an answer on May 31, 2026 at 9:03 am

    The loadItems() is a static function that loads the available statuses for certain “type” that you need, for example, for comments, or for posts. So for example, it prepares the available “status descriptions” for “posts” just before rendering the “post edit page” so you’ll have the needed values in the post status dropdown.

    The $model is instantiated inside this static function just before the lines you quoted. It means that while this is indeed static method, which means called without instantiating “Lookup” class, inside of it, it does other things. The Full stop here is to emphasize that a class method is a fully contained unit of code. It can do whatever it needs to do inside. In general, one doesn’t need to care about its internals (unless the person is designing and coding those internals, of course) but my point is that you need to grasp two distinct things here – the first is what this function does when referred to from the outside – and this is simply returning the lookup items for a certain class. The second thing is that internally, while being a static function, it instantiates some class objects, in our case objects of the same type – Lookup.
    This instantiation is done using Yii’s Active Record capabilities – the “findAll()” method which will do the needed SQL for you and return the result set of the found records as an array of instantiated objects of type Lookup.

    I hope this clears some… .

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.