cakephp

cakephp $this->data loses a LOT of its data array after form submit

我怕爱的太早我们不能终老 提交于 2020-01-06 18:12:45
问题 I have a manage_photos page whose $this->data contains a great deal of information about its Unit. I have a form which makes the appropriate changes in the database. However, upon submission of the form, $this->data (as seen when using pr($this->data)) loses MOST of its array data once the page refreshes. Here is the form code in my view: echo $this->Form->create('Unit', array( 'action' => 'manage_photos', 'type' => 'file', 'inputDefaults' => array( 'label' => false, 'div' => false ) ) );

cakephp $this->data loses a LOT of its data array after form submit

一笑奈何 提交于 2020-01-06 18:12:18
问题 I have a manage_photos page whose $this->data contains a great deal of information about its Unit. I have a form which makes the appropriate changes in the database. However, upon submission of the form, $this->data (as seen when using pr($this->data)) loses MOST of its array data once the page refreshes. Here is the form code in my view: echo $this->Form->create('Unit', array( 'action' => 'manage_photos', 'type' => 'file', 'inputDefaults' => array( 'label' => false, 'div' => false ) ) );

I need to count the today created account in Cake 3

馋奶兔 提交于 2020-01-06 16:11:07
问题 I need to count the users, but my condition is only if their account have been created today. I have a users table with a created field (datetime) for each rows. How can i do it in Cakephp, i didn't find the answer in the documentation. $usersNewCount = Number::format($this->Users->find()->where(['created' => 'CURDATE()'])->count()); I tried with CURDATE, and of course it's not working, i guess Cakephp has a specific function for te datetime field ? 回答1: What you are doing there won't work

Call to undefined method App::uses() - cakephp - CakeEmail

非 Y 不嫁゛ 提交于 2020-01-06 15:42:10
问题 I am trying to setup CakeEmail to use my gmail as my isp blocks port 25. However, I am having a very frustrating problem trying to load the App::uses class. I have tried placing it in many different locations and I still get the following error. Fatal error: Call to undefined method App::uses() in C:\www\ash\app\controllers\songrequests_controller.php on line 3 I am not sure whats going on. Am I not loading something properly, or am I not placing it in the correct place? <?php App::uses(

Call to undefined method App::uses() - cakephp - CakeEmail

扶醉桌前 提交于 2020-01-06 15:41:34
问题 I am trying to setup CakeEmail to use my gmail as my isp blocks port 25. However, I am having a very frustrating problem trying to load the App::uses class. I have tried placing it in many different locations and I still get the following error. Fatal error: Call to undefined method App::uses() in C:\www\ash\app\controllers\songrequests_controller.php on line 3 I am not sure whats going on. Am I not loading something properly, or am I not placing it in the correct place? <?php App::uses(

How to see the error message in $_FILE array in PHP

大兔子大兔子 提交于 2020-01-06 15:29:10
问题 I am working on multiple file upload functionality where I am getting error when I print the file array as: print_r($_FILE); Gets error as: Array ( [name] => _agiewniki_Forrest_in_Autumn.jpg [type] => [tmp_name] => [error] => 1 [size] => 0 ) I don't see the error description, the error only this [error] => 1 回答1: You can use this array to display file-upload error messages: $error_messages = array( UPLOAD_ERR_OK => 'There is no error, the file uploaded with success', UPLOAD_ERR_INI_SIZE =>

CakePHP 3.x: how to extend the Request class

杀马特。学长 韩版系。学妹 提交于 2020-01-06 15:14:34
问题 I have a plugin and I wish to extend the Request class ( Cake\Network\Request ), to add new methods and properties that can be used by the controllers of my plugin. How to do? Thanks. 回答1: Create your extended request class and simply pass an instance of it to the dispatcher in your apps webroot/index.php front controller: https://github.com/cakephp/app/blob/3.0.0/webroot/index.php#L35 // .... use App\Network\MyCustomRequest; $dispatcher = DispatcherFactory::create(); $dispatcher->dispatch(

CakePHP 3.x: how to extend the Request class

故事扮演 提交于 2020-01-06 15:14:17
问题 I have a plugin and I wish to extend the Request class ( Cake\Network\Request ), to add new methods and properties that can be used by the controllers of my plugin. How to do? Thanks. 回答1: Create your extended request class and simply pass an instance of it to the dispatcher in your apps webroot/index.php front controller: https://github.com/cakephp/app/blob/3.0.0/webroot/index.php#L35 // .... use App\Network\MyCustomRequest; $dispatcher = DispatcherFactory::create(); $dispatcher->dispatch(

Cakephp throws an error unless array is devided

限于喜欢 提交于 2020-01-06 15:06:59
问题 So i have an Api call where i get a json array: When i do the following: $data = $this->HasOffers->get_full_detail_report()['data']['data']; $this->set('data',$data); i get an error saying an internal error has occoured However if i do: $data = $this->HasOffers->get_full_detail_report(); $data2 = $data['data']['data']; $this->set('data',$data2); everything is working correctly. Now my question is why is this happening? and how can i fix it? 回答1: The syntax you are using in the first example

Containable won't filter 2nd level model with HABTM & hasMany

余生颓废 提交于 2020-01-06 14:35:37
问题 What I have: "A" HABTM "C" HABTM "A" through join table "B" "A" hasMany "B" belongsTo "A" "C" is ordered by a "B" field What I want: // result: [0] => array( A => array( /* single model's fields I still need*/ ), C => array( [0] => array( C.field1, C.field2, ... /* Model C fields*/ ), [1] => array( C.field1, C.field2, ... ) ) ) What I've tried: // this gives me data I don't need: A->find('all', array( 'conditions' => array( 'id' => $id ) ) ) // result: [0] => array( A => array( /* single