cakephp-2.0

CakePHP 2.3.1 updateAll query not working

余生长醉 提交于 2019-12-11 09:05:36
问题 I am not able to update records in CakePHP 2.3.1 Query: $this -> Staff -> updateAll(array('Staff.last_login' => date('Y-m-d H:i:s')), array('Staff.id' => $staff['Staff']['id'])); Error: Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use 回答1: See http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-updateall-array-fields-array-conditions :

Using a plugin component from shell class in cakephp 2.0.2

a 夏天 提交于 2019-12-11 07:57:12
问题 I would like to make use of a plugin component from my shell class. I am trying to use: App::import('Component', 'Myplugin.Mycomponent'); $this->Mycomponent =& new MycomponentComponent(); Unfortunately the above seems to fail. And I get an error message saying that the Component class could not be found. Any suggestion how I should tackle this? Thanks 回答1: you should always take a look at the test cases first! this way you would have found out that they are manually included this way: App:

CakePHP use MS Access database (.mdb, not accdb): Do I need to write a driver? How to build it?

帅比萌擦擦* 提交于 2019-12-11 07:38:41
问题 I'm in the unlucky situation where my client requires to use a read-only MS Access database to render some webpage contents on his website (built by me). Because this MS Access file will be updated roughly once per month and I don't want to do it manually by converting it into sql query and import in Mysql, I would like to make some webpages read directly from it. What I discovered is that there isn't a driver (at least in my cakephp installation) for MS Access database (but in older versions

How to add 2 callback to the Jshelper in Cakephp 2.x

纵饮孤独 提交于 2019-12-11 06:54:37
问题 I want to add 2 callback to Js->submit, My first return true or false. Continuing with that I want to put action. I mean If it is true then it continue to action else halt at that moment. What I have tried yet but its not taking 2 callback. Plaese help. echo $this->Js->submit("Apply", array( 'id' => 'submitForm', 'div' => false, 'class' => 'general_button', 'style' => array('float:none;', 'margin: 10px;'), 'url' => array( 'controller' => 'categories', 'action' => 'index', 'field' => $search

Core.php in cakephp 3

只愿长相守 提交于 2019-12-11 05:56:25
问题 I used to do some config with "routing.prefix" in cakephp2. It was in the file core.php. I notice there is no core.php in Cakephp 3. What is the equivalent of core.php in cake 3. 回答1: the core configuration file for cake3 is config/app.php http://book.cakephp.org/3.0/en/development/configuration.html but the routes go in the config/routes.php file http://book.cakephp.org/3.0/en/development/routing.html so If you want to have a named routing put it in routes.php http://book.cakephp.org/3.0/en

CakePHP pass custom query from controller into model paginate()

亡梦爱人 提交于 2019-12-11 05:49:10
问题 I am using Cakephp 2.X version Im going to run sql like: SELECT field1, field2, field3, field3, ( IF(LOCATE('abc', field1), 4, 0) + IF(LOCATE('abc', field2), 3, 0) + IF(LOCATE('abc', field3), 2, 0) ) AS score FROM sometable WHERE ( (field1 LIKE '%abc%') OR (field2 LIKE '%abc%') OR (field3 LIKE '%abc%') ) ORDER BY score DESC this sql is generated by code dynamically. So this sql need to be passed into paginate() function in order to do the pagination by cakephp. It seems that cakephp

Cakephp not loading css and js files

耗尽温柔 提交于 2019-12-11 05:42:51
问题 I seriously can't understand what is going on here. I just uploaded my web app from localhost to new domain-name on Windows IIS Server. When I try to access the web app, CSS files and images are not loaded and I get the following error: " CssController could not be found." I don't understand why it is doing this. Although I've written code like this in my default.ctp: echo $this->html->css('generic'); CSS files are placed in: app\webroot\css I have searched on Google and have tried everything

CakePHP Custom Route Classes - How to Pass Arguments?

試著忘記壹切 提交于 2019-12-11 04:47:10
问题 I've created a custom route class and I want to be able to pass in settings/options to the constructor so that it's configurable. Can this be done? Documentation for Custom Route Classes: http://book.cakephp.org/2.0/en/development/routing.html#custom-route-classes My custom route class: https://github.com/Signified/CakePHP-Model-Route-Class 回答1: You can probably just pass any settings/options you might have in the options of your Router::connect function. App::import('Lib', 'ModelRoute');

How to set selection in mulitiselect list box in cakephp

孤街醉人 提交于 2019-12-11 04:39:56
问题 I want to set the multi selection to my multi list box. I have two results in my view page. $inr1 = 0; $arr1 = array(); $str_arr = ''; foreach ($result as $rows){ $inr1 = $rows['Employees']['employee_id']; $arr1[$inr1] = $rows['Employees']['first_name'].' '.$rows['Employees']['last_name']; $str_arr = $str_arr.$inr1.','; } $str_arr = substr($str_arr,0,-1); //print_r($arr1); $inr = 0; $arr = array(); foreach ($options as $option){ $inr = $option['Employee']['employee_id']; $arr[$inr] = $option[

Cakephp Call to Undefined Method Set::numeric()

不想你离开。 提交于 2019-12-11 03:44:39
问题 I am attempting to port a PHP website into cakePHP which is proving somewhat difficult due to a ridiculous amount of incorrectly named columns in the database tables etc. etc. Anywho, I've gotten most of the way there after renaming many things,and I can bake the entire site without much issue. I can then browse the site normally (the baked version) and everything seems to work on the face of things however there is a table called 'sets' and it seems to cause a problem. Is there some special