Virtually all Yii applications are built on top of a database, and though Yii is very flexible in how it addresses your DB, some design choices make things more convenient than others.
Virtually all Yii applications are built on top of a database, and though Yii is very flexible in how it addresses your DB, some design choices make things more convenient than others.
If you have to display a overview of related data in a table, you can use the CListView, create your view with table/tr/td tags and implement db-queries in the view to display detaildata of the current (master-)record.
Ctrl+Space
.Ctrl+Q
.The two most commonly-used base classes in most Yii applications are CController
and CActiveRecord
, each extended to your own particular models and controllers.
Often, when writing widgets or editing Yii code, it is unclear whether or not the code is following the MVC pattern.
Many applications wish to obtain parts of the URL for the current page (the hostname, the query string, etc.), and the CHttpRequest
class wraps various $_SERVER
variables to break down the URL into its constituent parts.
The official Yii project site now supports OpenSearch. This means you can customize your browser's search box to enable direct search of the content in yiiframework.com. For example, by entering a Yii class name in the browser's search box, the corresponding class API page will be shown in the browser.
Almost all the information you need whilst working with yii is written in the Class Reference.
We often need to display a success page after the user has submitted a form without problem. We may show some welcome message after a user registers a new account. There are many ways to implement this workflow. In this article, I will explain a method that exploits flash messages.
First param in CActiveDataProvider could be a string with model name or instance of class. So, you may use CActiveRecord::cache() for cache, but you need set third param to 2, because you should cache 2 queries: counting and get data.
Here are all wiki articles from "Understanding" series by Yii wiki contributors:
The popular [CListView] and [CGridView] widgets each take a data provider and iterate over each data object produced, calling the user's code to render each row one at a time, and most are familiar with the use of the $data
variable to represent the current model object or array.
There are situations in which Active Record will generate nonsense queries from what a nieve Yii user might think is reasonable code. One such situation is a CActiveDataProvider
using CDbCriteria
to get data from parent and 1:n child table with a condition on the child table.
I saw many posts that community newbie is confuse in image/photo upload with random name. so I post this topic covering all useful things regarding to image/photo upload(not covering image attribute related functionality)
Most controls that are rendered by CHtml have an argument called $htmlOptions. This argument is an array that holds the attributes of the HTML element. For example the following code:
I've seen a lot of people asking about the logging facilities in Yii and thought I'd share a nice little class I wrote that provides near real-time logging.
To get null
from database instead of empty strings you need to set up your DB connection as follows:
Many time for SEO porpouses is important that each page will have a unique address.
My article Display the full record in a CJuiDialog uses ajax to view a record in dialog on clicking the 'view-icon'.