Wiki

Sorted by commentsX
Displaying 111-120 of 687 result(s).

Using counters with ActiveRecord

Created 2 years ago by davi_alexandreTips8 comments – viewed 18,861 times – ( +14 / -1 ) – version 1.1
Let's say, for example, that you are developing a blog or some kind of CMS and you want to track the number of times each post was viewed (maybe to show a list of the most viewed ones).

Accessing data in a join table with the related models

Created 2 years ago by fsbHow-tos8 comments – viewed 67,407 times – ( +26 / -1 ) – version 1.1
Sometimes the right place to store application data is in a join table. For example, movie viewers either like or don’t like the movies they watched.

Use shortcut functions to reduce typing

Created 5 years ago by qiangTutorials8 comments – viewed 39,252 times – ( +55 ) – version 1.1
Because Yii intends to be integrated nicely with third-party libraries, it does not define any global functions. Everything in Yii needs to be addressed with full class name or object scopes. For example, to access the current user, we need to use Yii::app()->user; to access application parameters, we need Yii::app()->params['name']; and so on. While editors like textmate can help alleviate the problem of these lengthy typings, it is worthwhile to define global shortcut functions to some commonly used method calls. They will make the application code look cleaner.

Saving files to a blob field in the database

Created 3 years ago by zaccariaTips8 comments – viewed 40,147 times – ( +9 / -2 ) – version 1.1
As a follow-up from the How to upload a file using a model wiki entry that explains how to save a file to the filesystem, this article will do the same using a blob field in the database.
tags: File upload

Custom Number Formatting or Decimal Separators and i18n

Created 2 years ago by c@cbaTutorials8 comments – viewed 29,421 times – ( +6 ) – version 1.1
By default, the decimal separator in php (also in mysql) is a dot (.). So when we work with floats in Yii (in calculations, validation, sql statements etc.), the decimal separator has to be a dot. If we want to use for example a comma (,) as the decimal separator, that is if we want to display numbers and enable users to enter numbers with a comma before the decimals, we have to...

Moving project code outside of webroot (plus multiple project support)

Created 3 years ago by Steve FriedlHow-tos8 comments – viewed 38,077 times – ( +22 / -1 ) – version 1.1
Yii's by-default directory organization works well enough, but there are several steps one can take that improve the security and serviceability of the system, especially in the context of multiple Yii projects on the same machine (including multiple versions of the same project).
tags: config, security

CSqlDataProvider in CGridView

Created 5 months ago by KonApazTutorials8 comments – viewed 5,410 times – ( +6 ) – version 1.1
In this wiki I will show how could use a CSqlDataProvider in CGridView with specific features

Displaying, sorting and filtering HasMany & ManyMany relations in CGridView

Created about a year ago by yJeroenTutorials8 comments – viewed 39,576 times – ( +18 ) – version 1.1
This tutorial gives you multiple options of how to fully implement showing, sorting and filtering related data in gridviews.

Using phpseclib with Yii

Created about a year ago by nkdHow-tos8 comments – viewed 6,071 times – ( +2 ) – version 1.1
I installed phpseclib because I needed to do some AES encryption in my project. After all the hassle of installing php lib, I found out that Yii already has a security module (securityManager). I finally decided to keep using phpseclib because it has one big advantage over Yii securityManager module, it does not requite mcrypt to be installed in the phpserver!
tags: security

An easy way to use escopes and CActiveDataProvider

Created 3 years ago by Rafael GarciaTips8 comments – viewed 20,937 times – ( +1 / -1 ) – version 1.1
Often used scopes to define criteria in our models. This is a very useful feature as it ensures that in any part of application applying the criteria defined by the scope when called it.