cakephp

Problem with storing large numbers in mysql DB

喜欢而已 提交于 2021-02-10 07:17:07
问题 I am using mysql db to save id's. It was working fine. But now an id like this 10000000754987. Is stored as 1.0000000754987E+14. How I can I fix it. The field is set to varchar 255 characters limit. I appreciate any help. Thanks. 回答1: You're apparently using PHP to generate that ID. Since you didn't mention what's exactly happening, I can only assume certain reasons for your database design. First off, you could store that number as bigint and not varchar . It's an integer you're saving, I

Saving a Disabled field

时光总嘲笑我的痴心妄想 提交于 2021-02-10 05:14:51
问题 In my edit.ctp I have a select box which I don't need the user to change. So I put array(disabled=>true) . But this field is not coming when pr($this->data); and showing an error while saving. What options are there to solve this issue. 回答1: You could make the field readonly so that user cant change it , or use some hidden field to post the data that you want, or you could use some css, like visibility:hidden , so that user dont see it but it'll be posted. echo this->Form->input('patient_id'

Saving a Disabled field

ε祈祈猫儿з 提交于 2021-02-10 05:14:32
问题 In my edit.ctp I have a select box which I don't need the user to change. So I put array(disabled=>true) . But this field is not coming when pr($this->data); and showing an error while saving. What options are there to solve this issue. 回答1: You could make the field readonly so that user cant change it , or use some hidden field to post the data that you want, or you could use some css, like visibility:hidden , so that user dont see it but it'll be posted. echo this->Form->input('patient_id'

CakePHP admin panel

ぃ、小莉子 提交于 2021-02-08 14:14:05
问题 I am new to CakePHP and want an admin panel on my custom CMS for a client. Is there any way other than just linking to an admin page to each controller that I can pull views from other controllers such as users and posts? 回答1: Here is a great article on creating a admin section for CakePHP Creating an Admin Section with CakePHP 回答2: BrowniePHP could be helpful. Its a plugin for CakePHP that will save you time on backend development work. 回答3: The better and cleaner way will be to put all your

CakePHP admin panel

我是研究僧i 提交于 2021-02-08 14:12:10
问题 I am new to CakePHP and want an admin panel on my custom CMS for a client. Is there any way other than just linking to an admin page to each controller that I can pull views from other controllers such as users and posts? 回答1: Here is a great article on creating a admin section for CakePHP Creating an Admin Section with CakePHP 回答2: BrowniePHP could be helpful. Its a plugin for CakePHP that will save you time on backend development work. 回答3: The better and cleaner way will be to put all your

CakePHP 3 Custom Route in Pagination

穿精又带淫゛_ 提交于 2021-02-08 11:02:55
问题 in my routes file i define a route for my controller method $routes->connect('/category/:cat', ['controller' => 'Categories', 'action' => 'category']); My controller method is this public function category(){ $this->paginate = [ 'limit' => 2 ]; $this->viewBuilder()->layout('newLayout'); $cat = $this->request->params['cat']; $id = $this->Categories->findBySlug($cat)->select(['id'])->hydrate(false)->toArray(); $cid = $id[0]['id']; $category = $this->ProductCategories ->find("all") ->select(['id

CakePHP 3 Custom Route in Pagination

半城伤御伤魂 提交于 2021-02-08 11:02:11
问题 in my routes file i define a route for my controller method $routes->connect('/category/:cat', ['controller' => 'Categories', 'action' => 'category']); My controller method is this public function category(){ $this->paginate = [ 'limit' => 2 ]; $this->viewBuilder()->layout('newLayout'); $cat = $this->request->params['cat']; $id = $this->Categories->findBySlug($cat)->select(['id'])->hydrate(false)->toArray(); $cid = $id[0]['id']; $category = $this->ProductCategories ->find("all") ->select(['id

CakePHP Delete with Multiple Conditions

落爺英雄遲暮 提交于 2021-02-07 19:16:56
问题 This is driving me mad. Why does Cake need to make simple things overly complex.. I am hoping to get Cake to generate SQL that looks like this.. I expect the SQL that runs to be DELETE `ProductVouchers` FROM `product_vouchers` AS `ProductVouchers` WHERE `ProductVouchers`.`id` = 16 AND `ProductVouchers`.`client_id` IS NULL; I am using delete() like this $this->ProductVouchers->delete([ 'ProductVouchers.id'=>$id, 'ProductVouchers.client_id'=>"NULL" ]); The log shows DELETE `ProductVouchers`

CakePHP Delete with Multiple Conditions

拥有回忆 提交于 2021-02-07 19:16:08
问题 This is driving me mad. Why does Cake need to make simple things overly complex.. I am hoping to get Cake to generate SQL that looks like this.. I expect the SQL that runs to be DELETE `ProductVouchers` FROM `product_vouchers` AS `ProductVouchers` WHERE `ProductVouchers`.`id` = 16 AND `ProductVouchers`.`client_id` IS NULL; I am using delete() like this $this->ProductVouchers->delete([ 'ProductVouchers.id'=>$id, 'ProductVouchers.client_id'=>"NULL" ]); The log shows DELETE `ProductVouchers`

Best way to upgrade a Cakephp project from Cakephp 2.6.2 to 3.8

半腔热情 提交于 2021-02-05 07:54:08
问题 I have been tasked with upgrading a legacy system from Cakephp2.6.2 to Cakephp3.8. Obviously the 2 are drastically different but is there a simple way of getting the old project to work with the new cake version? Or could anyone steer me in the right direction for the best way to do this? 回答1: There is no generic "best way" that fits all. The best way is the easiest way for your specific application that results in a properly working application, but that's something that you need to