cakephp

Unable to properly read json encoded success/failure statuses sent by Cake PHP controller function handling Ajax call

半城伤御伤魂 提交于 2020-01-15 10:42:43
问题 My problem is somewhat similar to cakephp, jquery, .ajax(), dataType: json, but my observations are little different. I am working on a Cake PHP project. Consider a group_assoc submodule of opstools module. So, there is this function group_assoc() inside opstools_controller.php which is invoked by an ajax call to update group associations. My ajax post is like this - $.post( url, function(data) { if(data) { alert(data.success); //alerts -> undefined alert(data); //alerts -> {"success":true}

CakePHP RequestHandler returns RSS/JSON instead of HTML

你。 提交于 2020-01-15 10:14:31
问题 I've been moving merrily along with my site until this week when we've started to see some errors crop up that have turned out to be related to my misunderstanding the way Cake's RequestHandler works, but I have yet to find a good workaround. I am using one method to lookup and return content in various formats, so that they all live on the same URL (maybe this is my error and I need to split them up?). So, in my controller I have: if ($this->RequestHandler->ext == 'rss') { to pick up on RSS

Model related to itself, bi-directional

本秂侑毒 提交于 2020-01-15 09:23:27
问题 I have a people table, where people are associated with other people by id. I believe this should be done with a separate table as is standard for such relationships, but I want to be able to retrieve the associated people when viewing a single record regardless of which key this record was stored as. For instance: table: people id | first_name | last_name table: people_associations id | person_one_id | person_two_id model: person $hasMany = array( "Associates" => array( "className" =>

Error: SQLSTATE[42000]: Syntax error or access violation with cakePHP

本小妞迷上赌 提交于 2020-01-15 08:34:12
问题 I am using the framework cakePHP for my application. I programmed it on localhost with xampp and try to upload it on my website now. It worked without any problems on localhost. Now there is only this one page, which does not work on the new server. The other sites (which use the database connection too) work alright. For this one site the following message appears: Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that

use controller method from model class in cakephp

此生再无相见时 提交于 2020-01-15 07:37:24
问题 In my cakephp project, I use afterSave() method of a model class. In this method, I want to call another method that is located in app_controller file. class MyModel extends AppModel { var $name = 'MyModel'; function afterSave($created) { $this->MyController->updateData(); } } Here updateData() is located in app_controller file, which is extended by MyController controller. The above code does not work, so how can i actually call updateData() in this case.. Please guide. Thanks 回答1: This is

CakePHP multiple checkbox array HTML the right way

纵然是瞬间 提交于 2020-01-15 06:10:44
问题 CakePHP's form generator for checkboxes ... when passing the following into the name: <?php echo $this->Form->checkbox('checkList[]', array( 'value'=>1,'id' => 'holiday'.$holidaysDays['id'], 'error' => false, 'placeholder' => false,'div'=>false,'label'=>false,'class' => 'approveHolidayCheckbox', 'data-off-text'=>'No', 'data-on-text' =>'Yes', 'hiddenField'=>true) ); ?> outputs: <input type="checkbox" name="data[HolidaysApproval][checkList[]]" value="1" id="holiday238" class=

cakephp having condition in find

元气小坏坏 提交于 2020-01-15 05:25:06
问题 can someone help me, and show me how to insert BEETWEN in having clausule in cakephp exampleo of my codE: $zaduzenja = $this->Zaduzenja->find('all',array( 'conditions' => array( 'Zaduzenja.placeno' => 0 ), 'fields' => array('Zaduzenja.obveznici_id', 'SUM(Zaduzenja.zaduzenje) as dug'), 'group' => 'Zaduzenja.obveznici_id HAVING array(dug BETWEEN ? AND ? => array('.$iznosOd,$iznosDo)' )); but this not working, i only want Calculated column "dug" to check if Dug >=$temp 1 AND Dug <=$temp2, but

How to: CakePHP logging in without password?

♀尐吖头ヾ 提交于 2020-01-15 02:38:07
问题 I'm trying to find a way to log in user without password. The reason is that I have phpBB3 forums in my site and the users already log in there. So I'm now building an expansion to the site to have more than just the forum (Using CakePHP). I thought that I could attach automatic account creation to CakePHP when user creates an account to forums (And ofcourse other link for the existing users). So the users would get CakePHP account that has the same username that they have registered in

How to: CakePHP logging in without password?

随声附和 提交于 2020-01-15 02:38:05
问题 I'm trying to find a way to log in user without password. The reason is that I have phpBB3 forums in my site and the users already log in there. So I'm now building an expansion to the site to have more than just the forum (Using CakePHP). I thought that I could attach automatic account creation to CakePHP when user creates an account to forums (And ofcourse other link for the existing users). So the users would get CakePHP account that has the same username that they have registered in

cakephp 2 redirect url with hashtag

ⅰ亾dé卋堺 提交于 2020-01-14 12:37:05
问题 I'm trying to redirect an url containing a hashtag(#) with cakephp's redirect controller function. When I use this code it url encodes the hashtag $this->redirect(array('action' => 'index',$menuItem."#article_id_".$created_id)); output: http://something.com/link%23article_id_62 Is there a way that 回答1: You need to use the # key: $this->redirect([ // ... '#' => 'article_id_' . $created_id, ]); 来源: https://stackoverflow.com/questions/8615516/cakephp-2-redirect-url-with-hashtag