Free Android CakePHP GMaps Articles by Bali Web Design

August 28, 2013

Problem with MAX_JOIN_SIZE using Cakephp

Filed under: cakephp,php — admin @ 8:07 am

I got strange error message when trying to upload to remote server. My client buy hosting and probably a shared hosting. The error message is this

Error: SQLSTATE[42000]: Syntax error or access violation: 1104 The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay

So i start to figure out, i believe this is related with server setting because the application run correctly locally without any error. So after google, i found fast solution to fix this problem

Edit /lib/Cake/Model/AclNode.php and add this line text after line 112. I am using cakephp 2.1.3

$db->query(‘SET SQL_BIG_SELECTS=1’); //Add this line
$result = $db->read($this, $queryData, -1);
$path = array_values($path);

It seem problem only on shared hosting. I hope this articles help you

July 16, 2012

How to remove Strict Standards warning error on cakephp

Filed under: cakephp — admin @ 11:48 pm

After upgrading PHP version into 5.3.5, i got several Strict standards warning error on my cakephp installation. The error are look like this

Strict standards: Redefining already defined constructor for class Object in C:\wamp\www\cake\libs\object.php on line 69
Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\cake\libs\object.php on line 94
Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\cake\libs\security.php on line 48

This message is really bother me, i have try to set debug option on cake core.php file, but it doesn’t solved the problem. The error still show up. So i search on google for the solution. And one solution is by setting php value for error_reporting into 6143. You can either set this value on php.ini or root .htaccess file.

set on php.ini

error_reporting=6143

(more…)

May 31, 2012

Remember me with manual Login are not work cakephp 2

Filed under: cakephp — admin @ 9:15 pm

I have been code a day to fix problem on manual login cakephp 2. I try to redesign my cms using the latest cakephp 2 version, which in my opinion are great improve especially for the performance of framework. However there are many thing are make me confusing and a bit frustating.

I have use the magic of login Auth function, which is fast to build a login form. However on certain condition we still need manual login using user parameter on the function. For example when coding for auto login using remember me function. The user data are save on cookie when remember me selected.

This function are nice when we want the user to have option to save their login data for certain period. In this scenario, as long the cookie data available on their browser cache, they will automatically login when opening the site. It is convenient for user because they don’t need to login everytime they open the site.

(more…)

March 13, 2012

Handling Error in Cakephp 2

Filed under: cakephp — admin @ 11:06 pm

Cakephp is a good framework, it include many aspect of building a website fast. Handling error in cakephp 2 is easy, by default you can change template for all type of error inside folder app/Views/Errors (in prior version app/views/errors). You can create each template for each error, such as

Http Error
error400.ctp
error404.ctp
error500.ctp, etc

Missing File
missing_action.ctp
missing_component_class.ctp
missing_component_file.ctp
missing_connection.ctp
missing_controller.ctp
missing_helper_class.ctp
missing_helper_file.ctp
missing_layout.ctp
missing_model.ctp
missing_scaffolddb.ctp
missing_table.ctp
missing_view.ctp

(more…)

May 25, 2011

Saving Mysql Function Now on Cakephp

Filed under: cakephp,php — admin @ 3:45 am

I think many cakephp programmer will get confuse when they want to save column/field on table with mysql function such as NOW(), CURDATE(), etc, We cannot use simple way of the saveField method or save method on model object.

This code will not save the data field into current date time on mysql.

$this->ModelName->saveField('date_field', 'NOW()');

or

$data['ModelName']['id'] = 1;
$data['ModelName']['date_field'] = 'NOW()';
$this->ModelName->save($data);

It will not work as you want. Because cakephp will ada quote on the value.

(more…)

January 19, 2011

strange id added on form create url cakephp

Filed under: cakephp,php — admin @ 9:18 pm

I found something strange on cakephp when i create form using FormHelper, a strange id appear on the action url. So i have this code on my view

<?php echo $form->create('Evoucher', array('url' => array('controller' => 'gift_vouchers', 'action' => 'buy', $giftVoucher['GiftVoucher']['amount'])));?>

It is generated a form tag with strange id added on action url. Something like this

<form id="EvoucherBuyForm" method="post" action="/gift_vouchers/buy/2/20" accept-charset="utf-8">

After exploration, i found the problem was on the controller action for buy. I have set id for the data variable

$this->data['Evoucher']['id'] = 2;

So after taking out this line, i change it into

$this->Evoucher->id = 2;

And cakephp can generate correct action url for the form tag

<form id="EvoucherBuyForm" method="post" action="/gift_vouchers/buy/20" accept-charset="utf-8">

I hope this tutorial help you. Thanks for visiting our blog

November 8, 2010

How to install cakephp on hostgator shared hosting

Filed under: cakephp,php — admin @ 8:03 pm

I just buy new shared hosting account for my new domain on hostgator. I want to install cakephp web application into this hosting. However the local setting or common setting that i used on other hosting is not work on hostgator. After figure out the problem, i found that the hostgator hosting does not allow for changing DOCUMENT ROOT setting.

So after research on cakephp tutorial, which come to setting cakephp on shared hosting and i think this solution also good for production phase. I will mention how i set my cakephp on hostgator (more…)

October 28, 2010

Redirect with exit using cakephp

Filed under: cakephp,php — admin @ 8:38 am

If you run redirect function on cakephp 1.1, don’t forget to add exit() function after redirect sintax. This thing can make security hole that confusing you. The purpose of adding exit() function after redirect sintax is to avoid php running others code after redirect function.

$this->redirect('controller/action');
exit();

However cakephp 1.2 give you default exit after redirect. The complete sintax for redirect on cakephp 1.2 is

$this->redirect('controller/action', null, true);

which the third parameter define exit = true, means terminate the script. second parameter is for setting exit status, for example 404, etc. Defaultly you only need to write

$this->redirect('controller/action');

get referer url using cakephp

Filed under: cakephp,php — admin @ 8:08 am

Sometime we need to get the referer url that access a page or url on our website. It is easy to find referer url using cakephp framework. Inside your controller or cakephp class, you can get the referer url using this sintak

Controller::referer()

Referer url is the last page or url that accessed by the user before open current page or url.

How to log your website using cakephp

Filed under: cakephp,php — admin @ 7:50 am

Cakephp is a good framework, it is a rapid web development framework for building any type of website. As a framework, cakephp has many built in feature. One of cakephp feature is build in logging system. Developer can easily log their application using cakephp.

Log function that can be accessed through your controller easily. You can save or add new log into error log or debug log, or you can make new log file. All file will be placed inside CAKEPHP_FOLDER/app/tmp/logs folder

default sintax that added to CAKEPHP_FOLDER/app/tmp/logs/error.log

$this->log("error message log");

(more…)

Newer Posts »