cakephp

help filtering data in cakephp

Im new to cakephp and Im having a little problem querying data. I have a User model and a Product model in a many to many relation. What I what is simply for my Products/Index action to only get the products associated to that User (the user is stored in session) and not all Products (which is what it does by default). Please help. ...

Find list in cakephp

Would recursive=-1 help in case of find("list") in cakephp. I mean any performance benefit ...

CakePHP: error when trying to use mssql datasource

Hi, This is my first time using ms sql with cakephp. Usually I use mysql. I've edited my database.php file: class DATABASE_CONFIG { var $default = array( 'driver' => 'mssql', 'persistent' => false, 'host' => 'jura', 'login' => 'sa', 'password' => '********', 'database' => 'clientportal', 'prefix' => '', ); ...

problem occures in if condition

I am tring to give condition, but it cant give appropriate result. like if($this->data['EmployeeExprienceDetail']['file_name']['type'] != 'image/jpeg') is this condition is ok or not...guide me thanks ...

problem displaying habtm relation of a specific user

Hi, I got 3 tables (Accessories, User, Accesories_Users)... At Accessories_Controller im trying just to get the accessories from the user logged in, so i set the recursive=1 and then execute the find... The problem is, if i do $this->Accessory->find("All", array('conditions'=>array('AccessoriesUser.user_id'=>$this->Auth->User('id'), ...

How do I create user-defined sql functions using CakePHP?

Consider the example given on this page about creating user-defined functions in SQL and then using the user-defined function in the WHERE clause. mysql> CREATE FUNCTION myFunction(in_rep_id INT) -> RETURNS INT -> READS SQL DATA -> BEGIN -> DECLARE customer_count INT; -> -> SELECT COUNT(*) ...

CakePHP 1.3: Detect ajax request in view

Before Cake 1.3 I would check for an ajax request with a simple $ajax->isAjax(). Now that the AjaxHelper has been deprecated, I'm looking for the proper way to check for an ajax request in my views. I can't find anything in the JsHelper or HtmlHelper methods. This seems like a really simple thing, I hope I'm not missing something obvious...

saving data for another model, and problems with redirection, in cakephp

When I save data in one model, I'd like to create some data in another model and save that too. Because I can't do this using beforeSave(), I eventually decided to use afterSave() to create new data items in my second model. I'm not writing a blog application, but to use the blog analogy it's equivalent to automatically creating a series...

Cakephp: Saving a Form via Ajax

i have a User Module where users can set their status message (tweet) from the profile page. When some one clicks Share it should go to an action and save the status message. I am not sure how to do this in CakePHP. I would wnna use jQuery. If you can point me to the right document. it would be of great help I am new to Ajax. ...

Cakephp Containable or Tree ?

I have a db with the following tables user(id, name....) restaurant(id, name...) module (id, name ) status_messages(id, pid, message, module_id, ModuleID) Module Refers to either Users or Restaurant. Both Users and Restaurants can have status_messages. When a user (id=21) sets a status message (1, 1, 'Message', 1, 21) When a...

(CakePHP) Form field missing content

I'm using Cake1.2 and have a CMS page which was working fine. Now it seems that someone has pasted in content from Word, which has obviously got lots of random ' and " characters in. The classic word ones. Now my form will not display the content. I have pr()'d my $this->data and all the content is there, hell I can even echo it out. I...

CakePHP AJAX request fails to show new content and uses wrong layout

I'm using CakePHP 1.3.2 with jQuery 1.4.2 and I'm seeing some strange behaviour with AJAX requests. Intermittently, when clicking an AJAX pagination link I'll see 2 POST requests instead of 1, the first of which is via XMLHttpRequest, the second of which isn't. The first request never completes, but returns a full page using the default...

Need help with Database Design

I have two Models - Users and Restaurants. They can set tweets like status messages and can have replies. i have the following setup and need your help to optimise the design. users(id, name, ......) restaurants(id, name.....) modules(id, name) [this table stores the modules - (1,user) and (2,restaurant) my message table status_mess...

Why can't I set up my cookie duration with cakePHP

So, I've tried many many things, but still always end up with Cookies that have the duration set to "Session" when looked at with Developers Tools in Google Chrome. Here are my current settings: core.php: Configure::write('Session.cookie', 'session'); Configure::write('Session.timeout', '3600'); Configure::write('Session.start', true);...

cakePHP paginate with left join causes incorrect number of pages

Hi everyone, I'm having an issue with cakePHP pagination, specifically when I do a left join. There are 6 rows returned, and with a pagination limit of 3, it should calculate 2 pages, but it calculates 3 pages, with the last page being blank. Here is the options array I'm passing to paginate: Array ( [fields] => Array ( ...

How do I fetch another websites info from a URL like Digg's submit button?

I'm creating a website using the cakePHP framework and I and a newbie to php and web programming. I want to do something similar to Digg's submit button, where you type a url and it fetches an image, title and sometimes a short description of the article on the webpage. I'm assuming this would be done using php but I'm open to any meth...

problem with form helper and list

hi, I want to make a SELECT item with the result of a query, I have this in the view: echo $this->Form->input('person_id'); I want the value to be the person's id, and display the concatenation of firstname and lastname, like so: <select id="ResearchGroupPersonId" name="data[ResearchGroup][person_id]"> <option value="2">lastname2...

Cakephp delete cache too many

Cake will clear a cached view if a model used in the cached view is modified When i update anything to expample table : posts it 'll delete all cache relate to posts as view, index/page:2,3,....., even search , anything have posts . It delete too much, can prevent it delete cache of action search or index,.., when update ? ...

display several tables in pagination

I am using cake php and mysql. I have several tables that all link up to a table called relates. The relates table holds the primary ids for all the other tables. example I have a table called clients its primary key is called id in the relates table its called client_id. heres my deal i created a crud application in cakephp it works...

cakePHP: Why are my model associations not working as a plugin?

I have a relationship as follows. Game -> hasMany Highscores Highscore -> belongsTo Games, Users When I run the MVC files standalone (within their respective places in the app dir), I get all belongsTo data associated with Highscores. However, when I run the same MVC files as a plugin, within the plugin dir, these associations are l...