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.. =)