cakephp-3.0

Translating query involving join table from CakePHP 1.3 to 3

﹥>﹥吖頭↗ 提交于 2020-01-17 12:24:10
问题 I'm migrating an application from Cake 1.3 to 3.0. My database has teams and people (with teams_people to connect them via belongsToMany relations) and divisions (teams belongTo divisions). The teams_people table has additional information, like whether the person's role on the team (captain, player), jersey number, position, that sort of thing. In the example below, I'm trying to read the list of teams in open divisions that a person is on, including their position, etc. $teams = $this-

Translating query involving join table from CakePHP 1.3 to 3

怎甘沉沦 提交于 2020-01-17 12:24:09
问题 I'm migrating an application from Cake 1.3 to 3.0. My database has teams and people (with teams_people to connect them via belongsToMany relations) and divisions (teams belongTo divisions). The teams_people table has additional information, like whether the person's role on the team (captain, player), jersey number, position, that sort of thing. In the example below, I'm trying to read the list of teams in open divisions that a person is on, including their position, etc. $teams = $this-

CakePHP 3.0 not running on other machines

主宰稳场 提交于 2020-01-17 06:12:07
问题 I've developed a small project on a machine, using CakePHP 3.0, and I need it to run on another machine. I've tried to install it on several other machines. If I run the composer to install the CakePHP 3.0, then I copy my stuff to overwrite it, the project works. I've tried this on two machines and had no problem so far. If I don't run the composer , and just copy the stuff to the target machine, it gives me the following error. I've tried this on 3 machines, and every machine gives me this:

Missing Controller Error on remote server using Beta 3

雨燕双飞 提交于 2020-01-17 03:59:14
问题 I've been working on a project on my local machine (running OS X with Cake server) using CakePHP 3 Beta. Sometimes I copy this project to a remove test server (running Ubuntu with Apache). Last time I copied all the files to the remote server, Beta 2 was the newest version, and the site was running just fine on both machines. When Beta 3 came out, I updated my local project and continued working on it on the local machine without running into any issues. Today I copied the whole project to

Cakephp 3 - var not transmitted to view when exception thrown

夙愿已清 提交于 2020-01-15 13:34:06
问题 In my AppController, I define a variable that must be used in every views (including error400.ctp, error500.ctp) of my app: // /src/Controller/AppController.php public function beforeFilter(Event $event) { parent::beforeFilter($event); $foo = 'bar'; $this->set(compact('foo')); } It works well, except when an exception is thrown (like NotFoundException): I get the following error: Undefined variable: foo in /src/Template/Error/error400.ctp Is this a normal behavior of cakephp? How could I fix

CakePHP 3: Exception handling / serialization in a RESTful API

不想你离开。 提交于 2020-01-14 02:59:22
问题 I'm building a JSON RESTful API with CakePHP3, but I'm not sure what is the best approach to handle errors and give the client information about the error. My approach so far is to throw a HttpException if (for example) saving an entity fails due to validation errors. In my controller I have the following: if (!$this->Categories->save($categoryEntity)) { throw new InternalErrorException('Saving failed'); } $this->set('status', 'Everything fine!'); $this->set('_serialize', true); If the saving

CakePHP 3: Exception handling / serialization in a RESTful API

半腔热情 提交于 2020-01-14 02:59:06
问题 I'm building a JSON RESTful API with CakePHP3, but I'm not sure what is the best approach to handle errors and give the client information about the error. My approach so far is to throw a HttpException if (for example) saving an entity fails due to validation errors. In my controller I have the following: if (!$this->Categories->save($categoryEntity)) { throw new InternalErrorException('Saving failed'); } $this->set('status', 'Everything fine!'); $this->set('_serialize', true); If the saving

What version of Foundation is used in cakePHP3?

為{幸葍}努か 提交于 2020-01-13 05:01:11
问题 From an earlier question (Responsive bootstrap designing in CakePHP 3x) I understand that cakePHP3 are using Foundation for front-end framework, but which version (in cakePHP v.3.2)? I'm struggling with a toggled top-bar, that won't open when minimized. There seems to have been some bugs in the 5th version and I'm now wondering if they aren't fixed in the version that cakePHP3 are using. 回答1: The CakPHP application templates base.css file was last updated with foundation on September the 1st

Dynamically change database connection in cakephp 3

梦想的初衷 提交于 2020-01-11 12:04:51
问题 I'm trying to change the database connection used in cakephp 3 on the fly. Every answer to this question that I found refers to cakephp 2 (These three for instance). This guy found a solution for cakephp 3 having a finite number of databases, and specifically defining which Database would be used by which Table file. The thing is that I want to create a new database for every new user, and change to his database when he logs in. I can't know in advance all the databases that will exist, to

CakePHP Query - Conditional Based on Contain Field

折月煮酒 提交于 2020-01-07 05:37:09
问题 I am developing a system that holds reports from customer's computers and displays failures in a list. I am attempting to write a query that locates all systems that have currently failed or have failures in the past. My model for Computers has a field that says last_report_pass that allows me to quickly find computers that failed on the current day. My Reports are associated with a computer ID and has a field called status that says whether it was a pass or fail. I am attempting to write a