MainelyDesign.com Blog

Mssql Tagged Blog Posts

Forcing A Single Join in CakePHP Pagination

Posted on 10/14/2011 at 09:25 am | Viewed 22,683 times | 0 comments

The devil's in the details... I was trying to make a really simple, dreadfully easy, database join in my CakePHP web application.  I've forced joins in Cake before, using the 'joins' key in the options array for find calls and paginate calls with no issue.  It was late and for the first time I only wanted to use a single join.  I copied the join code from a much more complex web app and pasted it into my new 'joins' conditions.  And then... I got SQL errors. 

Inserting NOW() into MySQL Using CakePHP

Posted on 08/11/2011 at 11:16 pm | Viewed 14,876 times | 0 comments

Great find.  If you want to insert NOW() into your query using CakePHP's save() or saveAll() functions, you can use the following expression:

$this->data['Model']['custom_date_field'] = DboSource::expression('NOW()');

Not sure how it works on MSSQL, but I will be testing that soon.

Cheers,
-Kevin Wentworth

Using Between with Date Ranges in Proper DB Date Format

Posted on 07/09/2009 at 11:56 am | Viewed 18,342 times | 0 comments

I need my CakePHP apps to run on both LAMP and Windows IIS using MSSQL Server.  Usually this isn't a problem because CakePHP does such a good job of database abstraction and database independence.  However, I came across a scenario the other day where I needed to select a date range using the BETWEEN SQL command.

Using CakePHP's BETWEEN function for date ranges

Pagination with MSSQL in CakePHP

Posted on 05/07/2009 at 04:36 pm | Viewed 16,915 times | 0 comments

One thing, and there are a few, that I can't stand about having to use PHP and MSSQL Server together is the lack of support for pagination.  With PHP and MySQL- no problem use limit.  MSSQL- can't do it without all these ugly sub-queries.  I have to give it to the CakePHP developers though, for the built-in support for pagination in MSSQL.  Albeit it is flawed, it works.

Full Tag List

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design