i'm trying to access the class CakeTime in my Model and CakePHP doesn't seem to recognize it.
Here's my code:
<?php
App::uses('AppModel', 'Model', 'CakeTime', 'Utility');
class Rex extends AppModel {
public function month_entries($created){
//création des mois qui vont servir de critère de recherche
$month=CakeTime::format("$created", '%Y-%m');
//on récupère le 1er du mois recherché
$month=$month."-01";
//on se place au premier du mois suivant
$month_plus_un=date('Y-m-d', strtotime("+1 month",strtotime($month)));
$count = $this->Article->find('count', array(
'conditions' => array(
'Rex.date_incident >='=> $month,
'Rex.date_incident <'=> $month_plus_un )));
return $count;
}
I get an error as soon as i call CakeTime.
am i missing something in syntax ? The documentation is unclear on how to call core library utilities in Model.
Thanks!
your App::uses(...) declaration is wrong, it shoulld be:
App::uses(string $class, string $package) , so, change:
App::uses('AppModel', 'Model', 'CakeTime', 'Utility');
to
App::uses('AppModel', 'Model');
App::uses('CakeTime', 'Utility');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With