cakephp-1.3

CakePHP - problem with HABTM paginate query

家住魔仙堡 提交于 2019-11-27 13:20:30
问题 Tables restaurants cuisines cuisines_restaurants Both restaurant and cuisine model are set up to HABTM each other. I'm trying to get a paginated list of restaurants where Cuisine.name = 'italian' (example), but keep getting this error: 1054: Unknown column 'Cuisine.name' in 'where clause' Actual query it's building: SELECT `Restaurant`.`id`, `Restaurant`.`type` ..... `Restaurant`.`modified`, `Restaurant`.`user_id`, `User`.`display_name`, `User`.`username`, `User`.`id`, `City`.`id`,`City`.`lat

CakePHP: best way to call an action of another controller with array as parameter?

徘徊边缘 提交于 2019-11-27 11:48:59
In a controller, what is the most appropriate way to call the action of another controller and also pass an array as parameter? I know that you can use requestAction to call actions within other controllers. But is it possible to pass arrays as parameters using request action? And no, I do not want to put the action in the App Controller. So that is not a solution for me. The only other way I know is to load the other controller as explained in: http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Configuration.html#importing-controllers-models-components-behaviors-views-and

Best practice to upload files in CakePHP

蓝咒 提交于 2019-11-27 11:22:37
问题 Can any one suggest me the best way to write code for uploading a file in CakePHP? I need to upload a file and save its name in table. If the record saving fails it should not upload the file. If the uploading fails then the record should be rollbacked. The code should be reusable I need to upload the file in afterSave callback 回答1: Edit (2015): Please see the Awesome CakePHP list for current file plugins (2.x branch here) Edit (2013): This answer is now a bit dated, so I will just leave a

Cakephp Auth with multiple “Users” tables

China☆狼群 提交于 2019-11-27 11:15:49
I would like to know how to deal with only ONE authentification process and "users" in multiple tables. I have 4 Users table: users, admins, artists, teamadmins which all have specific fields, but I would like all of these users to be able to connect via only one form on the homepage, and being redirected after that to their specific dashboards. I think the redirections shouldn't be a problem, and some routes added should work, but I really don't know where to look/start to ake this all possible. Cheers, Nicolas. EDIT : here's the final solution (thanks to deizel) App::import('Component',

Routing: 'admin' => true vs 'prefix' => 'admin in CakePHP

帅比萌擦擦* 提交于 2019-11-27 10:10:53
问题 Hi I'm setting up admin routing in CakePHP. This is my current route: Router::connect('/admin/:controller/:action/*', array('admin' => true, 'prefix' => 'admin', 'controller' => 'pages', 'action' => 'display', 'home')); It works fine, but I don't understand what the difference between 'admin' => true, and 'prefix' => 'admin' is. When I omitted 'prefix' => 'admin' , the router wouldn't use admin_index and would instead just use index . So what's the point of 'admin' => true ? 回答1: By setting

Saving HABTM with extra fields?

£可爱£侵袭症+ 提交于 2019-11-27 08:59:26
I am trying to save an order, and the products in the order. The order is being saved, but the products are not. I have an orders table and a products table and a orders_products table. In the Order model I set $hasAndBelongsToMany = 'Product'; on the orders_products table I have a couple extra fields: order_id , product_id plus price , quantity to capture the sale price and quantity sold. I am saving the data via: $this->Order->saveAll($data); Here is what $data is: Array ( [Order] => Array ( [user_email] => st@kr.com [billing_first] => Steve ... //more excluded [total] => 5000 ) [Product] =>

Paginate from within a model in CakePHP

末鹿安然 提交于 2019-11-27 08:08:22
I have a function in my Event model called getEvents - you can pass limit, start and end dates, fields , event types , and event subtypes . I read that paginate can accept all the parameters I'm using like joins , conditions , limit ...etc just like a normal find can. It returns data just fine when I don't try to paginate. But - I'd like to be able to pass it a paginate variable to tell it instead of doing this: $this->recursive = -1; $data = $this->find('all', $qOptions); to do this: $this->recursive = -1; $data = $this->paginate($qOptions); When I try that, though, it gives me lots of errors

How to eliminate php5 Strict standards errors?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 04:03:57
After upgrading my PHP to 5.4.3 (WAMP server 2.2), my web app made in CakePHP 1.3, is showing the following errors in my index: Strict standards: Redefining already defined constructor for class Object in C:...\cake\cake\libs\object.php on line 63 Strict standards: Non-static method Configure::getInstance() should not be called statically in C:...\cake\cake\bootstrap.php on line 49 I've found that some people solve this problem by setting the error_reporting in php.ini to E_ALL & ~E_STRICT . I did that in both php.ini files (C:\wamp\bin\php\php5.4.3 and C:\wamp\bin\apache\apache2.4.2\bin)

Paginate from within a model in CakePHP

橙三吉。 提交于 2019-11-27 04:00:11
问题 I have a function in my Event model called getEvents - you can pass limit, start and end dates, fields , event types , and event subtypes . I read that paginate can accept all the parameters I'm using like joins , conditions , limit ...etc just like a normal find can. It returns data just fine when I don't try to paginate. But - I'd like to be able to pass it a paginate variable to tell it instead of doing this: $this->recursive = -1; $data = $this->find('all', $qOptions); to do this: $this-

TypeError: $(…).on is not a function

故事扮演 提交于 2019-11-27 02:30:18
问题 I am using jQuery litebox. After adding JS and CSS files I got this error TypeError: $(...).on is not a function at this line in js file "return $('body').on('click', 'a[rel^=lightbox], area[rel^=lightbox]', function(e) {" Can anybody help me to understand the problem here? I am doing this implementation in CakePHP 1.3. 回答1: The problem may be if you are using older version of jQuery. Because older versions of jQuery have 'live' method instead of 'on' 回答2: The usual cause of this is that you