cakephp

containable on hasMany relationship

Greetings, I am trying to tear down query returned from find call using containable in CakePHP. for example I have 2 models, User and Post. User hasMany Post. Now when I am using containable on find call like so: $User->id = 1; $User->find('first', array( 'fields' => array('id'), 'contain' => array('Post') )) It will not re...

Formhelper to add a line Break in cakephp

Hi, The Form helper in cakephp echo $form->input('Firstname', array('class'=>'test','name'=>'Firstname','type'=>'text')); generates me like the following <div class="input text"> <label for="Firstname">Frrstname</label> <input type="text" id="Firstname" value="" class="test" name="Firstname"/> </div> is it po...

$ajax->link() doesn't work in Firefox?

I am reading Beginning CakePHP, and to make it so that you can vote on comments, it tells you to create a couple of AJAX links: <?=$ajax->link('<li>up</li>', '/comments/vote/up/'.$comment['Comment']['id'], array('update' => 'vote_'.$comment['Comment']['id']), null, false)...

User management, authentication and acl plugin for CakePHP?

Hi, I am pretty new to CakePHP, having been using rails for a little while. My question is, can anyone recommend a good user management, authentication and acl plugin or component for Cake? I have come across this one, but it has not been updated since 2008. If not can anyone recommend a good book/tutorial site for this kind of set up?...

$paginator->numbers(); not working in cakephp

Hi, i am trying to use the pagination concept in Cakephp for my application .. var $paginate = array( 'limit' => 5, 'order' => array( 'Report.report_id' => 'desc' ) ); ANd in the cakephp action $conditions=array('Report.user_id'=>$userId); $this->paginate['Report']['condit...

cakephp with oracle: no group by?

Greetings, I'm trying to use the 'group' parameter for a find using CakePHP. The dbms is oracle and to my surprise it didn't work (no group by in the query). Example: $this->User->find('all', array('group' => 'id')); The query returned: select * from users User where 1 = 1; digging around the source code at the DboOracle::render...

Can a CakePHP model change its table without being re-instantiated?

I'm working with an unchangeable legacy database schema where each instance of an object has its own table in the database with associated records. I need to change a model's useTable every time the model is instantiated, but retain Cake's nice caching and what not. Say I have many pad objects, which each have several note objects (Not...

Adding data before save in CakePHP

Post hasMany Tag: My form: $form->input('Post.title'); ... $form->input('Tag.0.name'); //1st tag $form->input('Tag.1.name'); //2nd tag This works perfectly, but... I create some fields Tag.n.name, and I want add each time one tag by $this->data['Tag'][some_number]['name'] = 'all'; Do not ask me why i want that, but tell me how i can ...

How to dynamically fill an input text field in CakePHP using Ajax?

I have an "Add Person" form with a few fields (name, address, phone number, etc). I want to be able to pre-fill some of the fields using information from other fields BEFORE submitting the form. For example, once the user puts in a city, an Ajax query will pull the area-code for the phone number (the Controller has a "city to area code...

Problem with CakePHP using autoModel when it shouldn't

I am getting an error in my view: Warning (512): SQL Error: 1054: Unknown column 'Model.id' in 'where clause' [CORE\cake\libs\model\datasources\dbo_source.php, line 525] $sql = "SELECT Model.model_id, Model.pic_location, Model.model_name FROM models AS Model WHERE Model.id = '20' LIMIT 1" $error = "1054: Unknown column '...

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

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 Controll...

Full view caching for dynamic routes in cakephp

I am having some issues with full view caching in cakephp. The url that I would like to cache is /posts/badge/23/size:180x150 I have been able to cache the view successfully by adding $cacheAction = "1 hour"; to the controller. Since I do not want to cache all methods in the controller (just specific methods) I tried to use the array s...

CakePHP newbie question: How to add non-database attribute to model?

I want to create a model that has SOME attributes that are not stored in a database. For example, I want to maintain an "age" field in the model, but I only store birthday information in the database (I can calculate "age" once the DOB info has been loaded). I tried adding a simple attribute to a model extension, but as far as I can tell...

Wildflower CMS is NOT a CakePHP plugin...Baked Simple CMS IS a CakePHP plugin...what's the difference?

Hello, I just started playing with CakePHP and I found Wildflower CMS . I like the idea and am going to start tinkering with it. I have a question, though. In the README, I found the following: "Wildflower is not and won't be a CakePHP plugin". What's the difference between Wildflower and something like 'Baked Simple', which claims to...

How to make login using either Username or email id.

Hello, I am developing a website in cakephp. I want to give facility to login either using username or emailid. I am using. $this->Auth->fields['email'] ='username'; when the login failed and try to relogin again. But till now i haven't got success. Can anybody suggest me any other idea to that or what i m missing. I have desabled t...

CakePHP Using Set::combine with localization

I am trying to use the localization features in cakephp. In app_model.php I have a method that gets the different payment methods. function getDistinctFields($model, $field) { $list = ClassRegistry::init($model)->find('all', array( 'fields'=>array("DISTINCT $model.$field"), 'conditions' => array('not' => array("$mo...

cakephp one to many custom relation joins

I have an Order table which has many IPN. However, I am not using cakephp conventions because the IPN table is from Paypal. I want to join the order table's order_num field to the IPN table's custom field. So it would be like: select * from orders left join ipn on orders.order_num = ipn.custom How do I set up the model relation correctl...

Why does a model from loadModel() saves twice in the db? I'm using CakePHP

hi when I try saving data using a model loaded from loadModel(), it saves twice on the database, why is that? ...

database tools for CakePHP

I'm a newbie to CakePHP and was wondering if there is any tool that can show my model classes and their relationship in a visual / graphical environment? ...

CakePHP inefficient database queries: can they be avoided?

My table structure: boxes (id, boxname) boxes_items (id, box_id, item_id) I was looking at the SQL logs for the "delete box" action, and am slightly horrified. SELECT COUNT(*) AS count FROM boxes Box WHERE Box.id = 191 SELECT BoxesItem.id FROM boxes_items BoxesItem WHERE BoxesItem.box_id = 191 SELECT COUNT(*) AS count FROM boxes_item...