cakephp

CakePHP core tests not working on IIS

ぐ巨炮叔叔 提交于 2020-01-05 10:31:30
问题 I'm following the steps (from http://book.cakephp.org/2.0/en/development/testing.html) to set up Testing on a CakePHP install. Viewing the core tests is supposed to be as simple as appending /test.php to my application's URL. But when I do that, I get an error page, saying... Missing Controller Error: Test.phpController could not be found. Error: Create the class Test.phpController below in file: my-app\Controller\Test.phpController.php Obviously, "test.php" is supposed to be a real file, not

Creating a CakePHP REST api from an existing project

≡放荡痞女 提交于 2020-01-05 10:18:31
问题 I have a webapp which I am planning on converting into a REST api and have decided to use CakePHP for this - the current form is written in ColdFusion. The database is a couple million records in size with 20 tables or so and a few associative tables that handle the many-to-many situations. I'm looking for the best method to start the CakePHP solution mainly in regards to the database. Should I import my existing db and just use cake to access its current form? Should I bake a fresh database

Email template not using themed version

瘦欲@ 提交于 2020-01-05 10:13:15
问题 I am using CakePHP 1.3 and the built in email features as described in the documentation. I have the html version of the template located in app/views/elements/email/html/reservation.ctp and its working as expected. $this->Email->template = 'reservation'; // no '.ctp' I also have a theme setup and most of the themed files are correctly overriding the default files. My problem is the themed email template is not being used when called from the themed site, its still using the email template

CakePHP 2.0 - customize database error message

心不动则不痛 提交于 2020-01-05 09:22:53
问题 I have a CakePHP 2.0 application with a MySQL database. Two database tables are connected with a 1:n relation and a foreign key constraint. So if I want to delete an entry which is connected in the other database table, I get the error: Error: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a forein key constraint fails (...) SQL Query: DELETE 'Test' FROM 'tests' AS 'Test' WHERE 'Test'.'id' = 10 Notice: If you want to customize this error message,

CakePHP model->find and IF condition in field

爱⌒轻易说出口 提交于 2020-01-05 08:52:25
问题 I need to construct a cakePHP model query like this: SELECT `Translate`.`var_name` , IF( prove_cn_sim =1, lang_cn_sim, lang_en ) FROM 'translate` AS `Translate` I've tried: $this->find("list", array( 'fields' => array("var_name","IF(prove_cn_sim = 1, lang_cn_sim, lang_en)"), )); but I got something like this: SELECT `Translate`.`var_name`, Translate.IF(prove_cn_sim = 1, lang_cn_sim, lang_en) FROM `translate` AS `Translate` CakePHP add table prefix to IF. do you know any solutions? 回答1: Try

cakephp 2.3 how to manage file upload for users and display the files when they are logged in?

廉价感情. 提交于 2020-01-05 08:44:33
问题 so far what I have managed to do is upload the file in app/files directory and download them using the deprecated media views. I am unable to use $file = $this->Attachment->getFile($id); and i want to display the images/files to the user, say like a profile image of the user. How can i get this done without comprising on the security of the user images. I get the error Call to a member function getFile() on a non-object I don't want to use any plugins for the same. Thanks in advance. 回答1: You

How to use cakephp export txt file

ぐ巨炮叔叔 提交于 2020-01-05 08:23:11
问题 I'm using cakephp framework.I want to export a database table of a client download in two formats.One is '.csv', the other is a '.txt'.CSV which I have passed 'csvHelper' resolved.Now I want to know how to export '.txt'.Sorry for my poor English, but I think you'll see what I mean, thanks! 回答1: Basically you set the header for the filename, like this: $this->response->type('Content-Type: text/csv'); $this->response->download('myfilename.txt'); Here are some functions I put in my appController

How to connect a post rest request to the add controller action using prefixes in cakephp

一曲冷凌霜 提交于 2020-01-05 08:23:10
问题 I code a client/server application. Server side is powered by CakePHP 2.4.7. Client side run with angularjs and cordova on mobile devices I use several cakephp route prefixes whose 'admin' and 'mobile'. (And I use $resource and $httpInterceptor angularjs factories to setup my REST requests.) I want to call /website/mobile/posts/add.json with json data posting. So I call /website/mobile/posts.json with a POST ajax query: The problem is here: the called controller action is 'index', not 'add';

Cakephp 3 - belongsToMany with _joinData

白昼怎懂夜的黑 提交于 2020-01-05 08:06:00
问题 I try to realize a bolongsToMany association with additional data in the join table. The join table has columns for the foreign keys and an additional column 'context' articlesController: $article = $this->Articles->patchEntity($article, $this->request->getData()); debug($article);die; and in a Plugin-Behavior: public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) { $data['Categories.Categories'] = ['id' => '1', '_joinData' => ['context' => 'Tag']]; debug($data)

Cakephp 3 - belongsToMany with _joinData

荒凉一梦 提交于 2020-01-05 08:04:33
问题 I try to realize a bolongsToMany association with additional data in the join table. The join table has columns for the foreign keys and an additional column 'context' articlesController: $article = $this->Articles->patchEntity($article, $this->request->getData()); debug($article);die; and in a Plugin-Behavior: public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) { $data['Categories.Categories'] = ['id' => '1', '_joinData' => ['context' => 'Tag']]; debug($data)