Tuesday, February 19, 2013

How do I add a decimal field in a Codeigniter Migration

public function up()
 {
  $this->dbforge->add_field(array(
   'Price' => array(
    'type' => 'DECIMAL',
    'constraint' => '10,2',
    'unsigned' => FALSE
   )
  ));

  $this->dbforge->create_table('ads');
 }

Tuesday, February 12, 2013

Wamp virtual hosts

Open C:\wamp\bin\apache\apache2.2.22\conf\httpd.conf
Uncomment
#Include conf/extra/httpd-vhosts.conf
it will be
Include conf/extra/httpd-vhosts.conf

Open C:\wamp\bin\apache\apache2.2.22\conf\extra\httpd-vhosts.conf to add/edit virtual hosts

Sample
NameVirtualHost *:80


    DocumentRoot "c:/wamp/www/"
    ServerName localhost
    ServerAlias www.localhost

Windows how to switch php version between 5.2 and 5.3



now you can switch php version




** WARNING : You must install Visual C++ 2010 SP1 Redistributable Package x86 or x64

VC10 SP1 vcredist_x86.exe 32 bits : http://www.microsoft.com/download/en/details.aspx?id=8328

Codeigniter cache model sample

model
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Countries_model extends CI_Model {

public function get_countries()
 {
  $query = $this->db->get('countries');

  if ($query->num_rows() > 0) {
   return $query->result();
  } else {
   return FALSE;
  }
  
 }

public function get_cache()
 {
  if ( ! $countries = $this->cache->get('countries')) {
   $countries = $this->get_countries();
   $this->cache->save('countries', $countries, 86400);
  }

  return $countries;
 }
}
controller
$this->countries_model->get_cache();