cakephp

CakePHP - Custom hasOne Object Association - Using a Join Table instead of in-table foreign keys?

In CakePHP, I'm trying to build a $hasOne relationship, but I can't add a foreign key to the tables (for legacy reasons). Is there any way I can create a join table (object1_object2) and link them together like this? I want to leverage Cake's powerful object relationship functionality, so if there's a way I can make this custom associa...

In CakePHP, why would $this->params['form'] be empty if I've just posted a form?

Using CakePHP 1.3, I post a form which correctly fills in $this->data. According to the docs, it seems like $this->params['form'] should be populated with some information as well, but it's simply an empty array. Is there a particular reason for that? The form is built using the Form Helper, as follows... Some relevant code: $defaul...

Pass data from javascript to PHP in cakephp

Hello I have a select element which has a few options. I am able to get the selected option when an onChange event is fired. Now I need to pass that option text to php, either with pageload or ajax. echo $form->select('data_source_select',$dataSourceOptions,null,array('escape'=>false, 'empty'=>'Select One','onChange'=>'getData(this)'));...

get data from database using Ajax in cakePHP

Hello I need to retrieve data from database via an ajax call. I am unable to find any good resources for this. Any help would be great. Thanks ...

Is there a better way to fetch OpenID infos from provider?

Hi, I am very new to the OpenID logic, so please excuse me if I am asking something trivial. I am using the OpenID component for CakePHP by Cakebaker, with the PHP OpenID library by JanRain. It's all working quite well, but I could not find an exhaustive way to retrieve user informations depending on provider and method (sreg vs. ax). ...

CakePHP Find - Order By String-To-Int?

I want to use CakePHP to pull an array of photos from a database, sorted by photo title (0, 1, 2, 3...) My query currently looks something like: $ss_photos = $this->Asset->find('all',array( 'conditions'=>array('kind'=>'photo'), 'order'=>'title' )); Unfortunately the titles seem to be in string format, leading to an undesirable s...

Can I use dynamically created form fields with the Security Component in CakePHP 1.3?

Using CakePHP 1.3, I have a (working) form that has dynamically created form fields (via Javascript). Everything works great, multiple models are saved via saveAll(), and it's just beautiful. But, I get black-holed to a 404 whenever I enable the Security component (hoping to get some of the auto-magic CSRF protection). I understand t...

converting dates between timezones in AppModel->afterFind (cakePHP)

I have a cakePHP application that is pulling data from two different databases, which store dates and times in their data from different timezones. One database's timezone is Europe/Berlin, and the other's is Australia/Sydney. To make things more complicated, the application is hosted on a server in the US, and times must be presented to...

CakePHP: question about Cookies expire

if 1 cookie is create by $this->Cookie->write('Rating', $cookie, true, '+1 months'); after 15 day, I read : $this->Cookie->read('Rating'); do somthing .... this $this->Cookie->write('Rating', $cookie, true, '+1 months'); Then now expire of rating cookies is 15 days or 1 month ? ...

How to Create This Route in CakePHP

I want to create a route something like: http://images.example.com/[models]/[sizes]_[filename].[extension] [models] = (blog|event|user) [sizes] = (t|s|l|o) [filename] = example [extension] = (png|gif|jpg) How do I create the route for this? I've tried the following w/ no success: Router::connect('/:model/:size\_:filename.:extens...

How to give 3 relations to same table in Cakephp

Hi i am new in cake php and can't solve the problem. The problem is I have a table like; id varchar(16) parent_id varchar(16) text text user_id bigint(20) is_deleted_by_user bit(1) is_deleted_by_us bit(1) who_deleted bigint(20) who_answ...

requestAction() does not go to the controller's function after beforeFilter(), from a shell class

Hi, In my CakePHP aplication, I use a shell script with a cron job which is working perfectly, except when it comes to call the requestAction() function. Thanks to my logs, I can see it going to the proper Controller->beforeFilter() function, but after that nothing happens. It neves goes into the specific function. I tried to output $t...

cakephp $uses or request action

Hi, i am in a situation where i need to fetch data from 6 models. i can't use associations as they are not related. So what should i use $uses or request action or any other solution ...

CakePHP auth session vs. cookie not updating

Hello, I have a ACL+auth driven app. Everything works fine but I discovered that user is logged out after a random period of time. After doing some research I discovered that the cookie set once doesn't change it's expiration date on page refresh. So it goes like this: I set up manually expiration time to 1 minute (Security.level low (...

how to implement a sorting subquery in the 'from' section?

I need to have a subquery order a table before joining so that when I group the table, the proper collapsed data is shown. For the example query, I want the latest start time before a given datetime (2006-08-26 00:00:00) select * from parts p left join (select * from transactions t left join transactiondetails td on(td.transaction_...

CakePHP Queries involving DateTime

I'm having some trouble working out how to do comparisons on a datetime field, in the course of a CakePHP query. I want for instance to be able to periodically delete all records from my database that relate to an event that occurred in the past. But I haven't gotten much further than: $this->Item->deleteAll( 'conditions'=>array('da...

Optimize this mysql query

Can some one optimize this mysql query SELECT submittedform.*, inspectors.first_name, inspectors.last_name FROM ( SELECT `dinsp`,`departure`,`arrival`,'cabin' as type FROM cabinets UNION SELECT `dinsp`,`departure`,`arrival`,'cockpit' as type FROM cockpits ORDER BY `date_of_inspection` ASC ) AS ...

cakephp find list

Hi I want to be able to generate a list using find so that I can use in select helper. but there is a problem. i want too fetch id,name(first + last). so how can I achieve it. I want first_name and last_name to be joined as name . How can I achieve it. $this->User->find('all',array('fields' => array('first_name','last_name','id'))); I...

Cakephp input to add/edit availability

Hi all, I have a table like this: CREATE TABLE `availabilities` ( `id` int(11) NOT NULL auto_increment, `structure_id` int(11) NOT NULL, `day` date NOT NULL, `status` int(11) NOT NULL, PRIMARY KEY (`id`) ) I need to create a calendar which would let me change the status of each day, i.e., set the status of each structure to...

Best/Fastest way to UPLOAD files

My users need to upload large amounts of files to a site (only HTTP access). Also, no matter how much I tell them to shoot the pictures in low resolutions they keep coming back with Massively sized images. Obviously, they complain that it takes them to long to upload all the files thru a simple HTML form - I'm planning on switching to SW...