Friday, July 3, 2015

No Tepon Tong Gas PETRONAS PV20

Perkhidmatan penghantaran gas memasak Petronas / Tong Gas Dapur Masak
Nombor Untuk Order GAS PETRONAS
Hanya Untuk PV20 - 03 - 4131 7338
Order tong gas lain, PV20 tak bagi masuk,
Cam hampeh kan.
So kene order dari no tu, kedai runcit kat bawah umah.. PV20, Off jln Genting Klang, Setapak


Wednesday, April 29, 2015

How to group by DESC order

You do group by, then you want to get the latest/smallest value. see below example

Table name `log`
idnamedate
1mia2015-04-10
2mia2015-04-03
3jame2015-04-11
4jame2015-04-13
5jame2015-04-01
6jame2015-04-15


select * from `log` group by name return below
idnamedate
1mia2015-04-10
2jame2015-04-11


select id,name,min(date) from `log` group by name return below
idnamedate
1mia2015-04-03
2jame2015-04-01


Another example: SELECT max(id) as id, asker FROM questions GROUP by asker

Tag: Give priority to ORDER BY over a GROUP BY in MySQL without subquery, SQL query ordering by alternating group ID

Thursday, January 8, 2015

Setup new project for Yii Framework

1. Download yii framework from their website
2. Extract and place whole folder into root folder. if its wampp it will be under www folder. if it xampp, under htdocs. The downloaded folder will have:
demos
framework
requirement
CHANGELOG
LICENSE
README
UPGRADE

3. Add below path at environment variable
C:\wamp\www\yii\framework;
C:\wamp\bin\php\php5.4.12;

4. Create new folder of your project inside root folder. Example: personal
5. Run yiic (command line tool) from cmd to create new project. Below code will auto generate
yiic webapp "C:\wamp\www\personal"
6. Default login admin/admin

Setup gii to create model - able to auto generate a page together with crud (create, read, update, delete operation)
1. enable things, find protected/config/main.php line 24
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>false,
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),

2. add menu, find protected/views/layouts/main.php line 31
'items'=>array(
array('label'=>'Gii', 'url'=>array('/gii')),
array('label'=>'Home', 'url'=>array('/site/index')),
array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
array('label'=>'Contact', 'url'=>array('/site/contact')),
array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
),

3. from gii page, click model generator. choose table to use to create a form/page. the label and input text are taken from table itself. set model name (any name).
4. from gii page, click crud generator. choose the model (newly created). click preview and generate.
5. Review the newly page created here. http://localhost/personal/index.php?r=post simply add the menu for this newly created menu as per below:
'items'=>array(
array('label'=>'Gii', 'url'=>array('/gii')),
array('label'=>'Home', 'url'=>array('/site/index')),
array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
array('label'=>'Contact', 'url'=>array('/site/contact')),
array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest),
array('label'=>'Post', 'url'=>array('/post'))
),