cakephp

Finding records via conditions in HABTM

混江龙づ霸主 提交于 2020-01-06 04:13:20
问题 I am trying to find posts within a category that are associated with a category. Right now, I have this: $this->set('posts', $this->Category->Post->find('all', array('conditions' => array('Category.uri' => $uri)))); But this doesn't seem to work. An error is showing this: Warning (512): SQL Error: 1054: Unknown column 'Category.uri' in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 684] ..<snipped>... Query: SELECT `Post`.`id`, `Post`.`title`, `Post`.`uri`, `Post`.`body

CakePHP shows 500 Internal Server Error

强颜欢笑 提交于 2020-01-05 17:36:09
问题 I'm having a problem with my CakePHP installation. I was developing it in a subfolder and it was working fine. But, when I move it into the root folder, it's showing 500 Internal Server Error. For example, it was working fine on: mysite.com/demo/ But, when I move it into the same server root, i.e. mysite.com/ it's showing the error. CakePHP Version: 2.2 As it was working fine on /demo/ folder, I think the mod_rewrite etc. are working fine, so that confused what's happening with the root

return number of contacts updated in google contacts through api

与世无争的帅哥 提交于 2020-01-05 14:10:11
问题 We have written code in cakephp to enter contacts in Google contacts through api , Contacts have added in Google through Google xml request , but how can we get total number of contacts added or updated in Google contacts after code successfully executed here is code: public function addContact($token=null,$atContacts=null){ foreach ( $atContacts as $contact ) { $xml = <<<'EOF' <atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'> <atom:category

How associations get defined when code is baked in Cakephp

孤街醉人 提交于 2020-01-05 14:04:02
问题 I was trying to bake the blog tutorial in console. I created one table named posts and baked the code and all MVC files were created properly. Then I created another table named comments and I again baked the code but no relationship gets defined by baking and comments was created as separate part from blog. I want to define has many relationship means blog has many comments. How will it get defined through console? Please give some idea? Or am I running bake incorrectly? Many thanks. 回答1:

Create a form with associations

筅森魡賤 提交于 2020-01-05 14:03:15
问题 Suppose I have a models A and B with A hasMany B. I would like to make a form to allow the user to add an instance of the model A, while also being able to add as many (associated) instances of the model B. However, doing something like echo $this->Form->input('A.B.some_field') in the form using the form helper does not have the desired effect. What is the best way to do this properly? 回答1: The key is to have form data which matches the format of find('all') / saveAll($data) You need

Setting up contains for a join table in CakePHP

早过忘川 提交于 2020-01-05 12:08:15
问题 In my application I have the following tables: Posts id title content Users id username password Profiles id user_id firstname lastname Comments id post_id user_id content Topics id title Topic_Posts id topic_id post_id Hopefully the relationships are fairly obvious! The problem I am having is that last table is a join table for the many to many relationship between Posts and Topics. I'm not entirely sure how to set this up! Here is my Models for Posts, Topics and Topics_Posts: class Post

permissions error running Console/cake

天大地大妈咪最大 提交于 2020-01-05 11:47:51
问题 I'm trying to run the cake console application for the first time. From the cake app folder I am running Console/cake then I get the following output PHP Warning: SplFileInfo::openFile(/var/www/virtual_host.com/public_html/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in /var/www/virtual_host.com/public_html/lib/Cake/Cache/Engine/FileEngine.php on line 314 Warning: SplFileInfo::openFile(/var/www/virtual_host.com/public_html/app/tmp/cache

Cake php 2.x project redirecting to wrong url after ACL implementation

ぐ巨炮叔叔 提交于 2020-01-05 10:35:47
问题 My Cake Php project is redirecting to the wrong url after I did the full implementation of ACL by following this tutorial -> http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-controlled-application.html. Problem - Correct redirect -> localhost/appname/ Redirect after I implemented ACL -> localhost/appname/appname/ This is the redirect that occurs after login. The public pages (Login) work fine. Below is Appcontroller code- public $components =

Cake php 2.x project redirecting to wrong url after ACL implementation

有些话、适合烂在心里 提交于 2020-01-05 10:35:06
问题 My Cake Php project is redirecting to the wrong url after I did the full implementation of ACL by following this tutorial -> http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-controlled-application.html. Problem - Correct redirect -> localhost/appname/ Redirect after I implemented ACL -> localhost/appname/appname/ This is the redirect that occurs after login. The public pages (Login) work fine. Below is Appcontroller code- public $components =

CakePHP core tests not working on IIS

北城以北 提交于 2020-01-05 10:31:31
问题 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