cakephp-3.0

Different results when retrieving data from different environments [duplicate]

主宰稳场 提交于 2019-12-11 20:21:22
问题 This question already has answers here : Error when retrieving associated data on. Linux only (2 answers) Closed 3 years ago . I've completed a project in my local environment running Windows 10. The production server on Debian OS I encountered an issue. Despite both my local env and prod env being run on the same Cakephp version, version 3.1.4, the same Cakephp database query $this->Articles->find()->contain('ArticleComments'); is returning two different results from an identical data stored

Cakephp 3 callbacks, behaviors for all models

▼魔方 西西 提交于 2019-12-11 20:12:34
问题 I just started reading cakephp 3 docs (I have been developing with cake 2.x for some time) and want to migrate some website from 2.x to 3. In cake 2 in my AppModel I have some callbacks, particularly beforeFind and beforeSave , that contain some logic concerning almost all tables in a database. Now in cake 3 there is no AppModel , how do I get the same thing done ? The best I can think of is to put that code in some behavior's callbacks, but I have like 30 models, should I load the behavior

AJAX JSON and routing in cakephp

此生再无相见时 提交于 2019-12-11 18:24:54
问题 I am trying to implement a search module by using AJAX. There is an index.ctp file in my Items Controller and I have linked my index.ctp file of Items to my search.ctp file which is present under Pages controller as below: <li><?= $this->Html->link(__('Search Products'),['controller'=>'Pages','action' => 'search']) ?></li> For the search.ctp pages the URL displayed is : http://onlineelectronic.com/pages/search In my search.ctp file the code is as follows: <head> <title> Search Results</title>

Stop CakePHP 3 from listing all fields in the SELECT query it generates with find()

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 18:16:44
问题 I'm trying to optimise a large MySQL query. I accidentally found out that a query with all fields listed ( SELECT Orders.id AS Orders__id, <...> ; the default CakePHP behaviour) takes 4 times longer compared to a query with just SELECT * FROM - 0.324 seconds vs. 0.084 seconds; checked several times. I'm wondering if I can disable this behaviour. I've tried: adding 'fields' => '*' to the find() options or calling ->select('*') , but it results in SELECT Orders.* AS Orders__* which throws an

Unexpected field 'g-recaptcha-response' in POST data on CakePHP 3

吃可爱长大的小学妹 提交于 2019-12-11 16:05:03
问题 I have created a site using CakePHP 3. I have static page which has contact us form something like this: inside contactus.ctp: <?=$this->Form->create(); ?> <?=$this->Form->hidden('form_type',['value' => 'contact']) ?> <?=$this->Form->input('name',[ 'label' => false, 'placeholder' => 'Your Full Name', 'required' => true ]); ?> <?=$this->Form->input('email',[ 'label' => false, 'placeholder' => 'Your Email', 'type' => 'email', 'require' => true ]); ?> <?=$this->Form->textarea('message',[

How to iterate over multiple result sets of a custom query?

自闭症网瘾萝莉.ら 提交于 2019-12-11 14:42:29
问题 I have a stored procedure in my mysql database which returns multiple query result sets. I want to access these results in my cakephp(V3.4) project using following code statements. $db = ConnectionManager::get('default'); $stmt = $db->execute("call mydatasp($paramlist)"); $result = array(); try{ do { $rowset = $stmt->fetchAll('assoc'); $result[]=$rowset; } while($stmt->nextRowset()); } catch(Exception $e){} After execution of this code block, I m getting error as [Cake\Error

Cannot edit my profile after changing the url link from user id to username using cakephp 3.4

梦想与她 提交于 2019-12-11 14:38:57
问题 I have this method to display a user profile like this one in url http://localhost/sample/users/profile/john instead of http://localhost/sample/users/view/1 public function profile($username) { $user = $this->Users->find()->where(['username' => $username])->first(); $accountUsername = $user->username; $this->set('profileUserName', $accountUsername); $this->set('users', $user); $this->set('_serialize', ['user']); } When I try to edit my profile It will always go to "You are not allowed to do

CakePHP Connection Refused in Browser

泄露秘密 提交于 2019-12-11 14:02:40
问题 I'm working on setting up/learning CakePHP for the first time and I am struggling to figure out why I cannot reach my server over the default port 8765. I like to develop on an ubuntu machine and work on the code remotely. The server is hosted on a vm on my local machine, but i am referring to it as the remote machine. Both the server and my remote machine are on the same 10.0.1.x subnet. I can reach the server over port 80 fine. However, when I attempt to reach hxxp://10.0.1.44:8765/ I get

display image from database

故事扮演 提交于 2019-12-11 14:00:06
问题 Table User image(blob type) ------------------------------ 0xFFD8FFE0 myController function displayImage($id) { $this->autoRender = false; $peoples=TableRegistry::get('peoples'); $peoples=$peoples->getRecord([ 'image'])->first(); header('Content-Type: image/jpeg'); echo $peoples['image']; } Model function getRecord($fields) { return $this->find('all')->select($fields); } But when I set this: <img id="imgPreview" src="displayImage/30"> the image does not show anything. When I use myController

CakePHP ajax CSRF token mismatch

橙三吉。 提交于 2019-12-11 13:52:12
问题 I am making an ajax request with Csrf component load in my AppController However I get the error {"message":"CSRF token mismatch.","url":"\/module_slides\/loadDeck.json","code":403} Here is the request header POST /module_slides/loadDeck.json HTTP/1.1 Host: www.hotelieracademy.com Connection: keep-alive Content-Length: 18 Origin: https://www.hotelieracademy.com X-XSRF-TOKEN: 3d3901b1de9c5182dce2877c9e1d9db36cdf46a6 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36