cakephp

Need to assign multiple attributes to records - should I opt for one table or multiple tables?

I am using an MVC pattern to represent a table with many records of music albums. To each music album there are attributes (genre, artist, ratings, etc). Each attribute can have multiple values (so the genre of one album can be both "pop" and "latin", for example). I want to represent those attribute values using table(s). So there are ...

Recommended method to handle record editing with approval in CakePHP?

I haven't been able to find any information regarding the best way to handle record editing with approval in CakePHP. Specifically, I need to allow users to edit data in a record, but the edited data should not overwrite the original record data until administrators have approved the change. I could put the edited records in a new tabl...

[PHP] Mystery, variable path name

This works: function upload($directory) { App::import('Vendor', 'UploadedFiles', array('file' => 'UploadedFiles.php')); echo $directory; $this->_saveUploadedFiles('C:/xampp/htdocs/freetickets/app/webroot/img/gallery/zantje_11042/'); } function _saveUploadedFiles($galleryPath) { $absGalleryPath = $galle...

Add to <body> tag of a cakePHP app

Hello, I have an app where I need to call some JS in the onLoad event of the BODY tag of two forms. However, I can't find how to modify the tag for just them. Does anyone know? Frank ...

CakePHP model validation with array

I want to use CakePHP's core validation for lists in my model: var $validate = array( 'selectBox' => array( 'allowedChoice' => array( 'rule' => array('inList', $listToCheck), 'message' => 'Enter something in listToCheck.' ) ) ); However, the $listToCheck array is the same array that's used in the view, to populate a ...

[CakePHP] Pass variable within controller

Hi, I would like to pass a variable from one controller function to an other. In other words, how can I access the variable from an other function, within the same controller? Thanks ...

CakePHP Variable becomes empty

<?php class UploadsController extends AppController { var $name = 'Uploads'; var $components = array('Auth'); var $uses = array('Upload'); function beforeFilter() { $this->Auth->allow('*'); } function upload($event) { App::import('Vendor', 'UploadedFiles', array('file' => 'UploadedFiles.php')); $user = $this->Auth->user('i...

Suggest a better flow for a quiz app in CakePHP

Here's the current flow of my quiz app: users/do_program quiz_contents/view quiz_questions/do_quiz The checking if the user has to do another module after finishing the current ones are in the quiz_contents and quiz_questions controller which I think can be improved because of the duplicate code. So what would you guys suggest? Some...

isset() or !empty() functions on all variables in your views? PHP

Hi I'm using CakePHP and I'm wondering do you guys puts isset() or !empty() around all of your variables in the views? Or should I depend on the data validation? What would be the suggested solution? ...

External Facbook connect site using multi friend invite, looses existing cakephp session

I have a facebook connect site. I am able to "login" to my site with the facebook api & fbml. I would like to give my users the ability to invite friends. I am using the multi invite and the form shows up fine. My problem is once the user either invites or cancels on the page, the request back to my application from facebook, causes ...

Changing only the home page layout in cakephp

If my whole site is using the default.ctp layout specified in apps/view/layouts/default.ctp, how do I change only the home page layout to use homepage.ctp and leave the rest of the site using default.ctp? ...

Cakephp - Updating information on a logged User

Hello, I have a controller named sales_controller at this controller I got a function in wich I want to: update information about the sale -> DONE create a new record on other model -> DONE update a field on a user record -> PROBLEM My last attempted to do this was: App::import('model','User'); $user= $this->Auth->user(); $nr = $t...

CakePHP: BeforeSave and AfterSave on entire save?

I'm having an issue with a misbehaving behavior. The short of it is that I am hooking into the beforeSave and afterSave callbacks using a behavior, but this has unintended consequences for my situation. Is it possible to replicate this? $this->Model->bsCallback(); if ($this->Model->saveAll($this->data)) { // Model might have other rel...

cakephp validation

i use validation in model like this 'email' => array( //'UniqueMail'=>array('rule' => array('checkEmailUnique', 'email' ),'message' => 'mail is used'), 'email'=>array('rule' => 'email','message' => 'mail not valid'), 'notEmpty'=>array('rule' => 'notEmpty','message' => '*'), ) and this validation...

How to setup cron job?

Hi, I have a windows shared hosting account with Godaddy.com with PHP5 that does not allow cron or scheduled job. I am developing a website in PHP5 with CakePHP and I need to run a cron job to send emails. What will be the best way to do it? Thanks for your answers in advance. :) ...

Cakephp - Deleting a record from a different model

Well this may be a question with a simple answer but I've been searching and couldn't find how to do this. I have the models: sales and follow. The table follow has an id, an user_id and sale_id. What I wan't to do is: on the sales_controller I need to find one follow record that has the user_id that is Authenticated and the sale_id tha...

How can I debug a PHP CLI script with xdebug?

I haven't quite figured this out. EVERY piece of documentation I've found covers how to use xdebug to debug scripts running in Apache. I need to debug a php CLI script. So, for instance, how do I pass the XDEBUG_SESSION_START variable in to get xdebug to kick on? I'm specifically trying to debug a CakePHP shell. So if anyone has any ad...

cakephp requestHandler check for swf/flash

Is there a way to check if a cakePHP action is being called from an swf/flash movie like there is for Ajax using the requestHandler? ...

CakePHP: Prevent GET form fields in URL

I've got a CakePHP search form that has 'type'=>'get'. Basically, one of the elements in the form is a submit button of type image. When the form is posted, in the URL I always get these x & y coordinates of the image submit button: http://site.com/controller/action?x=22&amp;y=36&amp;query=hello Is there any way I can prevent the coor...

CakePHP find('threaded') pagination

Hi, I'm kind of new to cakePHP and get to the moment where i have to do pagination. The comments table has a parent_id and the threaded query is working correctly so now, I want to paginate the results. My problem is the limited sql query affects all the retrieved comments and I only want to limit the parent ones because the other way...