cakephp

CakePHP and SQL Server 2008, Group By not working

Whenever I do a: $this->Job->find('all', array( 'group' => array('Job.some_field'), 'recursive' => -1 )); I get a : SQL Error: Column 'jobs.id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. With MySQL it works fine but with SQL Server 2008 it se...

php menu generated from a db

Hi there, I have a database with products organized by categories and subcategories. The thing is that I generate a menu by querying the categories table. Because categories are almost the same(they can change/add once a month or something), I don't think I have to query the database for each access of the web-page. Do you have a better...

Problem in adding a page link [CakePHP]

hi all actually when i use link syntax like <?php echo $html->link('Home', '/notes/index');?> but when i used <a href="/cake/cake_startab/notes/index/" alt="Home">Home </a> its woking why???? ...

Ordering columns in Rails, cakephp style.

CakePHP's built in pagination helpers automatically allow column ordering in the view. If you bake the view you get a link on each column to order it by that data. Is there a way to get this functionality in Rails? The standard will paginate doesn't offer it, anyone know any good ones? ...

Using Sqlite3 with CakePHP

Hello, I'm trying to run Sqlite3 with CakePHP. Yes, i know it's not officially supported, but this post here: http://stackoverflow.com/questions/1021980/cakephp-sqlite says it's possible. I've downloaded the new driver file "dbo_sqlite3.7.php" and put it in "cake/libs/model/datasources/dbo". Now I'm having trouble getting connected to t...

Update "Properties" model when adding a new record in CakePHP

Hi, I'm writing an application in CakePHP that, for now, is to be used to make quotes for customers. So Quote is a model. I want to have a separate model/table for something like "Property," which may be used by other models. Each time a user gets to the "Add Quote" action, I basically want to pull a Property called "nextQuoteNumber"...

how to authenticate an admin and user in cakephp

hi to all i am using cakephp framework for my project. but problem is that in my project there are four users like admin,user,employer,bla bla.if all are simultaneously login than how can i authenticate them to right access. so plz help me..... thanks in advance ...

Cakephp beforeFind() - How do I add a JOIN condition AFTER the belongsTo association is added?

I'm in Model->beforeFind($queryData), trying to add a JOIN condition to the queryData on a model which has belongsTo associations. Unfortunately, the new JOIN references a table in the belongsTo association, so it must appear AFTER the belongsTo in the query. Here is my Tagged->belongsTo association: app\plugins\tags\models\tagged.php ...

Cake PHP Routing issue

Hi, I need to do some special routing in cake, but can't for the life of me figure it out. I have a shop controller at /shop, the format of the url will be: /shop/:category/:sub_category/:product_slug In the routing I need to send each part of the url to a different action, for example if the url was just /shop/cakes it would go to t...

Merge entries in CakePHP

Let's say I have a Model, for example User, and I want to merge two instances of this Model, say merge User2 into User1. Explicitly this is what I mean: If a field is already filled in User1, it should remain the same If a field is missing in User1 but is present in User2, it should be copied If SomeModel BelongsTo User, every instance...

How to access a plugin model from a regular controller in PHP Cake 1.1

Hopefully a simple question: I've a plugin which uses a set of tables (kb_items, kb_item_tags, etc). and I'd like to be able to access these models from another controller (say, my Pages controller), thus: class PagesController extends AppController{ function knowledgebase(){ $items = $this->KbItem->findAll(...); } } I am admitted...

How do I display the record count of a related model with CakePHP?

I have two models. Lets say they are "Posts" and "Comments". In an admin view for Posts, I want to display how many comments are on that post. I am confused on where to put the code. In the controller or the view? I would like it to be in the controller. ...

CakePHP: how to get recently created auto-incremented field

I have a user submit a field to the database, it validates, and makes the entry. The primary key of this new row is auto-incremented. The user then gets to another form where that newly created field is required. Can anyone shed any light on this problem? Thanks in advance! ...

Find the closest locations to a given address

I have built an application in CakePHP that lists businesses. There are about 2000 entries, and the latitude and longitude coordinates for each business is in the DB. I now am trying to tackle the search function. There will be an input box where the user can put a street address, city, or zipcode, and then I would like it to return t...

Adding action in component in CakePHP

Hi, I'm trying to create a CakePHP component for JQuery datatables in server-side mode. I've got the datatable working but I want to componentize it so I can reuse it in multiple controllers. When I include my new component in a controller I want it to create a new action on that controller called tabledata to handle the XHR queries f...

CakePHP - How to use onError in Model

I've created a custom datasource which fetches data from a web api, and I'm now looking at implementing error handling. In the datasource, I'm calling $model->onError(). In the model, I've created the onError method, and I can access error details with $this->getDataSource()->error; However I can't redirect or set a flash message becau...

Deep containing and paginating in Cakephp

My Database is formed like this: Recipient belongs to a Distribution, Admin HABTM Distribution Now, when I want to find all the Distributions for which I am an Admin I do as follows: $userid = $this->Session->read('Auth.User.id'); $meineListen = $this->find('all',array( 'contain' => array( 'Recipient' => array( 'id' ), 'A...

CakePHP - Route configuration

Hello I am working on cakephp and totally a newbie to php/cakephp. Can you please tell me what is wrong with my route configuration here? Router::connect( '/news/:q/:page', array('controller' => 'news', 'action' => 'onDemand', 'mode'=>'news', 'page'=>1), array('pass'=>array('q','mode','page'), 'page' => ...

$this->Session->setFlash displays in wrong timings

Hi, I am using $this->Session->setFlash to flash the error messages to the browser and its working fine. But, unfortunately, it is displaying the messages when it shouldn't display also. It is seems like, its getting the information's from cache and displaying. Please let me know, is there any way to solve it? ...

mysql query the latest date

I am running this query SELECT sh.*, u.initials AS initals FROM database1.table1 AS sh JOIN database2.user AS u ON u.userID = sh.userid WHERE id = 123456 AND dts = ( SELECT MAX(dts) from database1.table1 ) ORDER BY sort_by, category In the table1 I have records like this dts status ...