Monday, November 7, 2011

CakePHP 2.0 bake

$ export PATH="{your cakephp directory}/lib/Cake/Console:$PATH
$ cd  {your cakephp directory}
$ cake bake


Sunday, November 6, 2011

dyndns vs ddclient

  • Register free domain in dyn.com
https://www.dyndns.com/account/services/hosts/add.html


It's free, although there are "Add to Cart" button




  • Install ddclient
CentOS guide


  • configure ddclient 


$ nano  /etc/ddclient/ddclient.conf
  • At the end of the ddclient.conf
    use=web, web=checkip.dyndns.com/, web-skip='IP Address'
    login={your-username}
    password={your-password}
    protocol=dyndns2
    server=members.dyndns.org
    {your registered domain} 

  • Save the ddclient.conf and restart ddclient
$ /etc/init.d/ddclient restart

PHP 5.3 : date.timezone

Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Kuala_Lumpur' for 'MYT/8.0/no DST' instead in /var/www/html/fridae/lib/Cake/Cache/Cache.php on line 513 Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Kuala_Lumpur' for 'MYT/8.0/no DST' 

To solve this in php 5.3, open the php.ini
$ nano /etc/php.ini

 Search [Date], and change the ;date.timezone = to
date.timezone ='Asia/Kuala_Lumpur'



 Restart apache

$ /etc/init.d/httpd restart

Refer:http://chrisjean.com/2011/06/24/php-5-3-and-system-timezone-settings/

Upgrade php 5.1 to 5.3 in CentOS

Remove PHP package 
 
$ sudo yum remove php php-cli php-common php-devel php-gd php-mbstring \
 php-mysql php-mcrypt php-pdo php-pear php-pgsql php-xml php-xmlr
Install PHP 5.3
$ sudo yum install php53 php53-cli php53-common php53-devel php53-gd \
 php53-mbstring php53-mysql php53-pdo php53-pgsql php53-xml php53-xmlrpc 
 
Restart apache
$ sudo /etc/init.d/httpd restart
Refer:http://chrisjean.com/2011/06/24/upgrade-php-5-1-or-5-2-to-5-3-on-centos/

Wednesday, November 2, 2011

Relationship Type

 class A extends AppModel {  
      var $name = 'A';  
      var $hasOne = array(  
           'E' => array(  
                'className'  => 'E',  
                'conditions'  => '',  
                'dependent'  => true  
           )  
      );  
      var $belongsTo = array(  
           'D' => array(     
                'className'  => 'D',  
                'foreignKey'  => 'd_id'  
           )  
      );   
      var $hasMany = array(  
           'C' => array(  
                'className'   => 'C',  
                'foreignKey'  => 'a_id',  
                'conditions'  =>'',  
                'order'  => '',  
                'limit'    => '',  
                'dependent'=> true  
           )  
      );   
      var $hasAndBelongsToMany = array(  
           'B' =>array(  
                'className' => 'B',  
                'joinTable' => 'as_bs',  
                'foreignKey' => 'a_id',  
                'associationForeignKey' => 'b_id',  
                'unique' => true,  
                'conditions' => '',  
                'fields' => '',  
                'order' => '',  
                'limit' => '',  
                'offset' => '',  
                'finderQuery' => '',  
                'deleteQuery' => '',  
                'insertQuery' => ''  
           )  
      );  
 }  


refer:http://book.cakephp.org/view/1040/Relationship-Types