cakephp-1.3

error in joining table in cakephp

…衆ロ難τιáo~ 提交于 2019-12-11 11:47:31
问题 Controller public function index(){ $this->Store->unbindModel( array('belongsTo' => array('Employee')), true ); $options=array( 'joins' => array( array( 'table' => 'Employee', 'alias' => 'Employee', 'foreignKey' => true, 'conditions'=> array('Employee.employee_store = Store.store_name') ) )); $coupons = $this->Store->find('all', $options); } Model class Store extends AppModel { var $useTable = 'store'; } Sql : SELECT `Store`.`id`, `Store`.`store_name`, `Store`.`store_address`, `Store`.`store

cakephp: Cookie does not read at view

时光总嘲笑我的痴心妄想 提交于 2019-12-11 10:46:21
问题 in controller i try this, and print $cookieee,its give me array $this->Cookie->write('User', $cookie, true, '+2 weeks'); $cookieee = $this->Cookie->read('User') echo "<pre>"; print_r($cookieee); echo "</pre>"; but My question when i print it any view file ,it doesnt print any values. i try to print it by using below echo "<pre>"; print_r($cookie); echo "</pre>"; echo $cookie['username']."=cokie="; and $cookieee = $this->Cookie->read('User'); echo "<pre>"; print_r($cookieee); echo "</pre>";

Data export to excel & save directly to the directory (folder)

霸气de小男生 提交于 2019-12-11 10:01:34
问题 Currently on clicking on export user is prompt a box to save/open the export excel file to their system , though what i want is when user click on export/send data , the data get exported & save to the server on specific folder & later which I mail that file to the user as an attachment. Did I have to make any change in my header for the same ? For ref below is the header from my export excel library: header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment;

using sql union on same table in cakephp find query

不想你离开。 提交于 2019-12-11 09:22:08
问题 let's say I have a query like this: (SELECT * FROM user WHERE id < 5 order by id DESC LIMIT 1) UNION (SELECT * FROM user WHERE id = 5) UNION (SELECT * FROM user WHERE id > 5 LIMIT 1) How can I translate the above query into a CakePHP find('all') query? Thank you 回答1: Using Model::find('neighbors') Rewriting this to a find('all') will be problematic, however find('neighbors') may fit your requirements; See the documentation find('neighbors') This should give you the data you need, but you will

HasMany Relationship and ID from other Model in CakePHP

萝らか妹 提交于 2019-12-11 09:13:29
问题 I am wondering whether it is possible to create a hasMany Relationship in a Model which makes use of the ID of the logged in user. Example: One tip has many votings (from different users). This is easy: public $hasMany = array( 'TipVoting' => array( 'className' => 'TipVoting', 'foreignKey' => 'tip_id', 'dependent' => false, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' )); Now I want to get all

Returning a lot of rows in CakePHP & MySQL

爷,独闯天下 提交于 2019-12-11 07:58:15
问题 Maybe I'm missing something easy here...or maybe I've just been coding on this so long I can't see past my problem, but using CakePHP (1.3) and doing a select (MySQL) should be able to return results even if there are, say, 2,000 records... right? $options = array( 'conditions' => array( 'Lead.campaign_id' => $campaign['Campaign']['id'] ), 'recursive' => -1, 'order' => 'Lead.goal DESC', 'contain' => false, ); $leads = $this->Lead->find('all',$options); Yet, this query gives me a white screen

accessing controller variables in model CakePHP

我的未来我决定 提交于 2019-12-11 07:38:24
问题 I have two variables in my controller in CakePHP which are accessed using $this->data['General']['q'] $this->data['General']['typesearch']. How Do I refer to these variables in the model??? 回答1: You didn't specify why do you need those variables in your model. Because the context is very important for this kind of questions, it's hard to accurately answer the one without it. Well, you could try defining variables in your model first: Class MyModel Extends AppModel { var $q; var $typesearch; }

Cakephp ACL redirect when a user has insufficient privileges

折月煮酒 提交于 2019-12-11 07:28:24
问题 First you should be aware that I am a new cake convert. Ok, from what I can tell when a user try's to visit a url they do not have sufficient privileges for, the ACL redirects them to "/" if Auth has loged them in, and login if the user is not already loged in. Also Auth remembers the requested page and on a successful login will attempt to redirect you there, again if you do not have sufficient privileges ACL redirects the user to "/". My question is when the ACL detects that the user does

In CakePHP 1.3, is there a callback for use after a `saveAll()`?

廉价感情. 提交于 2019-12-11 07:05:52
问题 Using CakePHP 1.3, is there is a callback that is fired after a saveAll() on a model, or a way to implement such a behavior? Maybe afterSave() already does this? Specifically, I would like to run a couple particular methods, but only after related items have been saved , and only if the parent item is a newly saved instance. Something like the $created argument, passed to afterSave() , obviously seems perfect, but I'm at least 90% certain that afterSave() is called on a model after the

Where/how to store custom functions (or methods) in CakePHP

江枫思渺然 提交于 2019-12-11 06:54:12
问题 i need to have several functions in cakephp application (for some regular expression matching). which is best way to store them, so i can access to them in every controller action? tnx in adv! 回答1: I would recommend you store the functions in the AppController class. All of your controller classes inherit from this controller. Also create the app_controller.php file in the root folder of your application if you have not already. 回答2: Or, if the actions aren't typical controller actions - you