CakePHP does not use my models

It’s not possible to give a directly-working answer because: There’s nothing wrong with the code in the question. That probably means you aren’t running your own code at all. Given that the only answer that can be given is advice, the only class that matters for the example in the question is Owner. Check filenames … Read more

SQLSTATE[HY000] [1045] Access denied for user ‘username’@’localhost’ using CakePHP

That error message usually means that either the password we are using doesn’t match what MySQL thinks the password should be for the user we’re connecting as, or a matching MySQL user doesn’t exist (hasn’t been created). In MySQL, a user is identified by both a username (“test2”) and a host (“localhost”). The error message … Read more

Request Entity Too Large PHP

post_max_size and upload_max_filesize are PHP.ini settings. You can set them either directly in PHP.ini or via ini_set. I don’t know if this can be set with some Cake-internal tools as well. However, the error could also be caused by a set limit of the RequestBodyLength in Apache (assuming you are running under Apache).

Why are date/time values interpreted incorrectly when patching/saving?

Date/time values are being casted/parsed in a locale aware fashion Update: this is the default behavior with the CakePHP application template versions prior to 3.2.5. As of 3.2.5 locale parsing is not enabled by default anymore, which will make the date/time marshalling logic expect a default format of Y-m-d H:i:s instead. In the marshalling process, … Read more

CakePHP 3.0 -> Between find condition

Expressions Between expression are supported out of the box, however they only support the first case without additional fiddling: $Query = $Table ->find() ->where(function($exp) { return $exp->between(‘start_date’, ‘2014-01-01’, ‘2014-12-32’, ‘date’); }); If you’d wanted to handle the second case via the between method, then you’d have to pass all values as expressions, which can easily … Read more

CakePHP 2.0 – How to make custom error pages?

Try this: /app/Config/core.php Exception render need to set as an AppExceptionRender. Example: Configure::write(‘Exception’, array( ‘handler’ => ‘ErrorHandler::handleException’, ‘renderer’ => ‘AppExceptionRenderer’, ‘log’ => true )); /app/Controller/ErrorsController.php class ErrorsController extends AppController { public $name=”Errors”; public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow(‘error404’); } public function error404() { //$this->layout=”default”; } } /app/Lib/Error/AppExceptionRenderer.php App::uses(‘ExceptionRenderer’, ‘Error’); class AppExceptionRenderer extends ExceptionRenderer { public … Read more

CakePHP find method with JOIN

There are two main ways that you can do this. One of them is the standard CakePHP way, and the other is using a custom join. It’s worth pointing out that this advice is for CakePHP 2.x, not 3.x. The CakePHP Way You would create a relationship with your User model and Messages Model, and … Read more