Saturday, 31 March 2012

YII Framework model findAllByAttributes()

For Yii Framework findAllByAttributes():


Obj::model()->findAllByAttributes($filterArr, $conditionArr);

$filterArr: To generate the SQL conditions in WHERE clause.
                 e.g., array('filter1'=>'v1', 'filter2'=>'v2'...)
$conditionArr: To generate the SQL other conditions (order by, limit...)
                 e.g., array('order'=>'v1 DESC', 'limit'=>'10',...)

e.g., if our SQL is: 

SELECT id FROM user WHERE username = 'jack' ORDER BY creationdate

The following code may achieve this:

$filterArr = array('username'=>'jack');
$conditionArr = array('order'=>'creationdate');
User::model()->findAllByAttributes($filterArr, $conditionArr);


帮自己宣传一下刚上线的网站 梦奇网;目前的提供的服务是 签证搜索 和 时间和日期。谢谢大家支持,SEO下!

YII Framework href - absolute path

For YII framework. In Views, href can be either a relative or absolute path.


For absolute path settings: Just add a prefix - http://


e.g., http://www.google.com directs you to google's website.
         www.google.com directs you to yourwebroot/www.google.com








Thursday, 22 March 2012

MySQL Generates random integer

FLOOR(0 + (RAND() * 1000))

from 0 to 1000!

MySQL Generates random date


A random date in 2009

mysql> SELECT FROM_UNIXTIME(RAND() * (1262246400 - 1230796800) + 1230796800) AS `the_date`;
+---------------------+
| the_date            |
+---------------------+
| 2009-04-27 05:01:04 |
+---------------------+
1 row in set (0.00 sec)