Wiki

Articles in category "tips", sorted by ratingX
Displaying 61-70 of 135 result(s).

An important tip when you are using CArrayDataProvider.

Created about a year ago by sirin kTips0 comments – viewed 7,228 times – ( +8 / -1 ) – version 1.1
Yii ‘s CArrayDataProvider is very helpful to display model relation data's directly on it.But it is truely a confusing one because by default it will assume a table field named “id” as primary key for its pagination purpose and what if you dont have field named “id” as primary key on your table? so its truely confusing and if you tried to display without an “id” field on ur table you will get an error like “yourmodel.id is not defined”.

Update two models with one view

Created 2 years ago by sensorarioTips11 comments – viewed 30,393 times – ( +10 / -2 ) – version 1.1
Suppose to have two models: Users and Emails. You do not want to store email in a Users model. And User can have 0 or many emails. This is the form generated to create a new user (just username).
tags: database, model, view, form

Saving files to a blob field in the database

Created 3 years ago by zaccariaTips8 comments – viewed 39,563 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

Managing constants easily

Created 2 years ago by briiC.lvTips4 comments – viewed 9,916 times – ( +4 ) – version 1.1
For time to time i have models with constants (basicly status constants) which i use in diferent places and if these constant changes, i have to change mentions of constant in code elsewhere.

CButtonColumn and Font Awesome icons

Created 11 months ago by DerekCTips3 comments – viewed 9,054 times – ( +4 )
I was looking for a way to use Font Awsome icons instead of the default images in a CGridView -> CButtonColumn. Perhaps this will be useful to someone.

How to catch and log MySQL deadlock errors

Created 2 years ago by sebTips1 comment – viewed 8,123 times – ( +4 ) – version 1.1
This method allows to log InnoDB monitor output when deadlock error occured. This way we will have much more useful data to find and fix deadlock.
tags: database

Access log output from unit tests

Created 2 years ago by MikeTips2 comments – viewed 5,024 times – ( +4 ) – version 1.1
Say, you want to write a test for a component which provides a caching feature. How would you know, that some method of your component returns a cached result? With the solution described here you can inspect all log outputs. So you could search the logs for accesses to the DB to really make sure, that the result was served from cache.

Get notified about the status of a Facebook user in your web app using periodic Ajax calls.

Created about a year ago by sirin kTips0 comments – viewed 4,935 times – ( +4 ) – version 1.1
hello, This article is helpful only if you have the following situation: A web app which uses facebook login to login its users and if a user is logged out from his/her facebook account through another browser tab, then your app dont know that he is logged out out or not from his facebook account and he/she will remain as logged in your web application.Its ok if you have no problem with this situation.But if you want to forcefully logout the user from your application if he is logged out from his facebook account means you can try this example.This example uses periodic ajax calls to facebook's graph api to check whether the user is logged in or not.
tags: facebook, user

Preventing CJuiTabs from hiding drop-down CMenu items

Created 3 years ago by Steve FriedlTips1 comment – viewed 8,265 times – ( +4 ) – version 1.1
Almost all Yii applications use CMenu at the top of each page to show options available to the user, and many include drop-down components to allow more fine-grained selection.

Syntax check

Created 3 years ago by Russell EnglandTips2 comments – viewed 5,932 times – ( +4 ) – version 1.1
So I've been busy making lots of modifications to my views/models/controllers - came to test the app and got a blank screen. Nothing in the application.log file so must be a syntax error somewhere... But which file?
tags: php, syntax