Monday, June 20, 2011

Codeigniter: SQL Select query FROM_UNIXTIME

I keep having error when I made this sql select:
$this->db->select("FROM_UNIXTIME( LOGTIME, '%D %M %Y') AS date");

And how to fix it, is by adding FALSE on db select like example below:
$this->db->select("FROM_UNIXTIME( LOGTIME, '%D %M %Y') AS date", FALSE);

Sunday, June 19, 2011

Codeigniter: Having error on Model query

I keep having this error: Call to a member function query() on a non-object Anytine I try to make query on model, And I found how to fix the issue:

1. Edit file application/config/autoload.php line 55:
- $autoload['libraries'] = array();
+ $autoload['libraries'] = array('database', 'session');
2. Edit file application/config/config.php line 228 by editing key
- $config['encryption_key'] = '';
+ $config['encryption_key'] = '123456789'; // add ur key here
And it works!

Friday, June 17, 2011

Codeigniter: Remove index.php on url

After many months stopping to learn codeigniter, now I am back to learn it again. So my first issue I have got after successfully installing it is, having "index.php" on the url, I read on user guide about how to remove it, but it did not fix the issue, so I looked it up in google and found the way to remove it.


So this is how to remove the default index.php from the url:
1. edit the file application/config/config.pho line 29:
-  $config['index_page'] = 'index.php';
+ $config['index_page'] = '';
2. create new .htaccess file on the root folder, then add below snippet:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
That is it.. =)

Tuesday, March 1, 2011

Stay loyal with Drupal ^^

I have been working at new company for 3 weeks, and I thought I was going to leave Drupal for CodeIgniter ^^ But I was wrong, I am needed there to work on e-Commerce site which is going to use Drupal. So I guess I will stay loyal with Drupal :D.


On my first day, I was given an assignment to figure out a project that is going to be re-developed using Drupal. So for the past 3 weeks I have been trying too figure out of the database diagram that was not documented by the previous developer, I have to think harder to figure it out. Now I think I know what I have to do for the next step.


And because there's nobody in my team knows Drupal, I plan to give them training an hour everyday, hopefully it's going to be easy.


Good luck Ning~

Monday, January 3, 2011

Cancel button on Drupal form

For few hours I have been trying to figure out of how to create cancel button on Drupal form, and I finnaly I found this way!

  $form['cancel'] = array (
    '#value' => t('Cancel'),
    '#type' => 'button',
    '#attributes' => array('onclick' => 'location.replace("'. referer_uri() .'"); this.form.reset(); return false;'),
  );

location.replace is to redirect url to the previous page, but also we need to reset the field value using this.form.reset() so it wont return an error.