cakephp-2.0

how to use cakedc/search plugin for searching across 3 different tables with 1 search bar?

大城市里の小女人 提交于 2019-12-11 19:39:29
问题 I am using CakePHP2.4 and the search plugin https://github.com/CakeDC/search I have the following Employee hasOne EmployeeProfile Employee hasMany Qualification So I have a single search bar. the search bar will search using LIKE through the following fields Employee.name EmployeeProfile.email Qualification.title how do I configure the model Employee->filterArgs for this search? This is a cross-posting of the original issue here 回答1: The documentation includes an example. 'username' => array(

CakePHP can't find table after creating a table

烈酒焚心 提交于 2019-12-11 19:28:57
问题 I create a table directly by a query. I only want to Import some data. Therefor i execute a query which is built dynamicly and i try execute this query in a Component-class. (I use a random existing model to execute this query is there a better why?) $query= "CREATE TABLE IF NOT EXISTS testerdbs ( 'Ü1' varchar(6) COLLATE utf8_swedish_ci DEFAULT NULL, 'Ü2' varchar(6) COLLATE utf8_swedish_ci DEFAULT NULL, 'Ü3' int(3) DEFAULT NULL, 'Ü4' varchar(6) COLLATE utf8_swedish_ci DEFAULT NULL, 'Ü5' date

Add class to pagination links at CakePHP 2.2

随声附和 提交于 2019-12-11 16:26:31
问题 I can add a class ("myclass") to the link (previous or next) which does not contain a link.(current page) I just add the class following the default ones: echo $this->Paginator->prev('< ', array(), null, array('class' => 'prev disabled myClass')); And it generates something like this: <span class="prev myClass disabled ">prev</span> But, when the previous or the next links have a link, then i the class is not added and it generates something like this: <span class="prev"> <a href="/tickets

Cakephp 2 request data and model

巧了我就是萌 提交于 2019-12-11 16:08:21
问题 I have 2 models. Order & OrderProduct When an Order to is added, Im trying to manipulate the OrderProduct data in the beforeValidate() of the Order Model but unsuccessfully. I've tried. (Both in Order model) function beforeValidate() { parent::beforeValidate(); $this->data['OrderProduct']['total'] = 1000; return true; } function beforeValidate() { parent::beforeValidate(); CakeRequest::data('OrderProduct.total', 1000); return true; } But the OrderProduct data isnt being modified when viewed

using Console/cake on EC2

不羁岁月 提交于 2019-12-11 14:28:58
问题 I'd to use the cakephp console on EC2 by this code : sudo cd /path/to/cakephp/app && Console/cake But weirdly I got this message: No such file or directory 回答1: Solved by installing dos2unix . First you have to install dos2unix sudo yum install dos2unix or sudo apt-get install dos2unix Then run: sudo dos2unix /path/to/app/Console/cake Maybe you need also to grant chmod -R 777 app/Console 来源: https://stackoverflow.com/questions/31888769/using-console-cake-on-ec2

Easy way to add case insensitive routing in CakePHP 2

安稳与你 提交于 2019-12-11 12:07:30
问题 Router::connect('/(?i:about)', array('controller' => 'pages', 'action'=>'display', 'about')); used to work in CakePHP 1.2 but it seems to not be working in CakePHP 2.x The only other solution that I see is to use the options to set a regular expression that will match against the a flag in the rout, but it seems rather convoluted for something so simple: Router::connect('/:aboutFlag', array('controller' => 'pages', 'action'=>'display', 'about'),array("aboutFlag"=>"[aA]bout")); Is there an

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: Session->write() not working

心不动则不痛 提交于 2019-12-11 09:57:12
问题 I'm building a very basic auth system for specific pages which require a password to view. I've found several other questions that sound similar, but the only ones with clear solutions involve config settings that don't seem to resolve my problem. For some reason $this->Session->write(...) always returns false. Here's my config setting: Configure::write('Session', array( 'defaults' => 'php' )); Here's where I try to write the session in the controller action: private function _handle_auth

Define global variable for Models and Controllers at CakePHP 2.2

坚强是说给别人听的谎言 提交于 2019-12-11 09:43:37
问题 Currently i am using something like this: //at bootstrap.php file Configure::write('from', 'mymail@mydomain.com') //at controllers or models files $var = Configure::read('from') The thing is, i would like to manage that variable through the database to be able to modify it in a simpler way. I was thinking about doing it with AppModel but then it would only be accessible for Models and not controllers. What should I do in this case? Thanks. 回答1: You can create a separate model / plugin which

handling unknown status codes [CakeException] Unknown status code

China☆狼群 提交于 2019-12-11 09:19:12
问题 How would I handle gracefully failures of another http server i'm talking to via HttpSocket? Haven't been able to find any good examples Stack Trace: 2014-02-01 07:00:35 Error: Fatal Error (256): [CakeException] Unknown status code #0 /home/alterscape/lab/cakephp/lib/Cake/Error/ExceptionRenderer.php(212): CakeResponse- >statusCode(110) #1 [internal function]: ExceptionRenderer->error400(Object(SocketException)) #2 /home/alterscape/lab/cakephp/lib/Cake/Error/ExceptionRenderer.php(175): call