cakephp-3.2

CakePHP 3 : delete and update array from cookie

这一生的挚爱 提交于 2019-12-12 02:09:32
问题 I'm using CakePHP 3.2 for writing a shopping cart application. I'm using cookie to add items to the cart. Now I want to update and delete value from cart. so that if user clicks on the same product add to cart with a different quantity value the existing record will be deleted and new will be added to cart. This is my addToCart() method. public function addToCart() { $this->loadModel('Products'); if ($this->request->is('post')) { $p_id = $this->request->data('product_id'); $p_quantity = $this

How to rollback cakePHP 3.2 to 3.0

一世执手 提交于 2019-12-12 01:37:42
问题 I did my project in cakePHP 3.0. By updating the composer my project converted into cakePHP 3.2. I want to rollback from 3.2 to 3.0. I tried rollback options too,that is also not working. How to rollback 3.2 to 3.0 ? 回答1: The rollback command supporty by composer is for the composer itself, ie it rolls back your composer installation to an earlier version, not anything that might have been installed via composer. To change the version of the cakephp/cakephp dependency, simply require the new

Display data from two different tables in the index() using cakephp.

倾然丶 夕夏残阳落幕 提交于 2019-12-11 13:25:35
问题 I've created a form where I need to display a table for which the data is coming from two different tables. The data is coming from Branch table. This Branch table contains a foreign key PrimaryContactID(int) which will contain the primary key of Employee table. Now, in the index page I have display all the details from the Branch table, except for the PrimaryContactID. Instead of that I need to display the names from that table. This is how I tried: controller: public function index() {

In cakephp 3 I got error Unexpected field in POST data

倾然丶 夕夏残阳落幕 提交于 2019-12-11 02:22:33
问题 In cakephp 3 I got error Unexpected field in POST data. Actually that field is not in my table, but I want to use in controller. 回答1: The Security Component in CakePHP is not forgiving. If you want to allow a field thru that should not go thru the Security Component hashing process, you need to use the unlockedField method that comes with the FormHelper class as such: $this->Form->unlockField('field'); If this does not work, you will need to provide us with the pertinent code 回答2: I was

Show custom field in query list in cakephp3

北战南征 提交于 2019-12-08 05:04:27
I want to create a dropdown with custom field but my list query append id field into the query. How to show only selected fields in my query. $this->loadModel('CardTypes'); $cardTypes = $this->CardTypes->find('list')->select(['code', 'name']); In my view $this->Form->select('card_type_id', $cardTypes, [ 'default' => 'DELTA']); see the manual $cardTypes = $this->CardTypes->->find('list', [ 'keyField' => 'code', 'valueField' => 'name' ]); 来源: https://stackoverflow.com/questions/38831063/show-custom-field-in-query-list-in-cakephp3

Login redirecting in cakePHP 3.4

ε祈祈猫儿з 提交于 2019-12-08 03:23:53
问题 I'm trying to redirect to current page after logged in, using cakephp 3.4 but I'm getting like this localhost page isn't working, locahost page redirecting you too many times. Try clearing your cookies for 2 sec after that it's redirecting to home page. Please help me out here. Here my code In appController.php public function initialize() { parent::initialize(); $this->loadComponent('RequestHandler'); $this->loadComponent('Flash'); $this->loadComponent('Auth', [ 'authorize' => ['Controller']

Find by conditions on associated model in CakePHP 3

吃可爱长大的小学妹 提交于 2019-12-04 12:44:13
I have two tables orders and sub_orders . Their association is $orders->hasMany('SubOrders', [ 'foreignKey' => 'order_id' ]); Both tables have invoice_no and sub_invoice columns in orders and sub_orders respectively. I have to find records from orders table containing associated sub_orders where $trackingId will match either Orders.invoice_no or SubOrders.sub_invoice $findOrder = $this->Orders->find('all', [ 'conditions' => [ 'OR' => [ 'Orders.invoice_no' => $trackingId, 'SubOrders.sub_invoice' => $trackingId ] ], 'contain' => [ 'SubOrders' ] ]); But this gives error Column not found: 1054

QueryBuilder limit is working for only first row in cakephp 3.2 [duplicate]

倖福魔咒の 提交于 2019-12-04 06:29:06
问题 This question already has an answer here : How to limit contained associations per record/group? (1 answer) Closed 3 years ago . Hii i am new to cakephp 3.2 v. Here i have used model association (hasMany). Here in bind section (campaign_videos) ,i want to fetch only one record , so for this ,i have put below code to manage it. my actual data in db. [ { "id": 1, "user_id": 95, "campaign_videos": [ { "id": 1, "campaign_id": 1, }, { "id": 3, "campaign_id": 1, } ] }, { "id": 2, "user_id": 95,

Fatal error because an Error instance is being passed instead of an expected Exception instance

◇◆丶佛笑我妖孽 提交于 2019-12-02 16:01:08
问题 I just installed xampp with php 7.0.4 and a fresh cakephp 3.2.6. I did a lot of research and everything I found shows that they are compatible. However as soon as I go to open the application with a browser, cake replies with an Internal Error. The only pointer as to what to do is that xampp logs the following in apache error.log: PHP Fatal error: Uncaught TypeError: Argument 1 passed to Cake\Error\BaseErrorHandler::handleException() must be an instance of Exception, instance of Error given

QueryBuilder limit is working for only first row in cakephp 3.2 [duplicate]

Deadly 提交于 2019-12-02 12:28:09
This question already has an answer here: How to limit contained associations per record/group? 1 answer Hii i am new to cakephp 3.2 v. Here i have used model association (hasMany). Here in bind section (campaign_videos) ,i want to fetch only one record , so for this ,i have put below code to manage it. my actual data in db. [ { "id": 1, "user_id": 95, "campaign_videos": [ { "id": 1, "campaign_id": 1, }, { "id": 3, "campaign_id": 1, } ] }, { "id": 2, "user_id": 95, "campaign_videos": [ { "id": 2, "campaign_id": 2, } ] }, $fetchCampaignFirst = $this->Campaigns->find()->contain(['CampaignVideos'