Recent Posts
- (09/10) Fixing Warning: the ECDSA host key for 'github.com' differs from the key for the IP addressTAGS:Web Server Admin
- (12/26) CakePHP 3 - Getting List of Column Definitions from a Table (like schema())TAGS:CakephpCake3
- (09/14) Change Order of Loaded Behaviors in CakePHP 3TAGS:Cake3CakephpWeb ProgrammingPhp
- (05/29) CakePHP 3 - Accept JSON Header Only Working When Debug FalseTAGS:Web ProgrammingCakephpCake3
- (05/23) Remove All Events from Google Calendar (Reset Calendar)TAGS:Web ProgrammingPhp
- (11/08) Google Tag Manager (GTM) Not Firing Default PageView EventTAGS:Web ProgrammingJavascriptGoogle Tag Manager
- (10/13) In PHP, how do you get __toString() Magic Method Result without calling echo?TAGS:CakephpCake3Cakephp 13PhpWeb Programming
- (11/14) Getting output from shell_exec() at all timesTAGS:Web ProgrammingWeb Server Admin
Subscribe to my feed
MainelyDesign.com Blog
Mysql Tagged Blog Posts
Forcing A Single Join in CakePHP Pagination
Posted on 10/14/2011 at 09:25 am | Viewed 22,679 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.
Read: Forcing A Single Join in CakePHP Pagination | View: Comments
Inserting NOW() into MySQL Using CakePHP
Posted on 08/11/2011 at 11:16 pm | Viewed 14,874 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
Read: Inserting NOW() into MySQL Using CakePHP | View: Comments
Best PaginateCount for CakePHP - with Group By Support
Posted on 08/07/2011 at 05:03 pm | Viewed 20,077 times | 0 comments
I'm been muddling my way through pagination with multiple joins, and complex filtering. I finally got it all working (more on that later, maybe....) when I noticed that I couldn't paginate my results. Everything was working fine until I added a "group" parameter to the find call. Instead of getting the right count, I got a count of 1! A quick look at my sql log tables (at the bottom of the page) and I saw that I had actually returned all the mysql records that were needed! If only there was a way to use them...
Read: Best PaginateCount for CakePHP - with Group By Support | View: Comments
Changing CakePHP's Model useTable on the Fly
Posted on 11/02/2010 at 05:12 pm | Viewed 18,702 times | 0 comments
I finally found an answer to/solution to something I've never been able to get around in CakePHP before: dynamically changing/setting the useTable value in a model. You can't just say $this->CakePHPModel->useTable = 'cakephp_table_name'; Instead you have to use the following function:
Setting CakePHP Model useTable Dynamically
Read: Changing CakePHP's Model useTable on the Fly | View: Comments
Getting All ACL Permissions in One Lookup (CakePHP 1.3)
Posted on 09/19/2010 at 11:36 am | Viewed 21,266 times | 1 comment
The biggest hurdle I've had to overcome migrating my CakePHP application from 1.2 to the much improved 1.3 branch involves Plugins and the ACL component. A while back I noticed that my backend was kind of sluggish due to all of the ACL lookups (that happen with each request) so I optimized my ACL database tables. At that same time, I also discovered an incredible mysql query that would lookup all of the ACL permissions for a particular ARO. This setup worked great... until I started upgrading to CakePHP 1.3.
Read: Getting All ACL Permissions in One Lookup (CakePHP 1.3) | View: Comments
Global Mysql Find and Replace with CakePHP
Posted on 08/31/2010 at 09:03 am | Viewed 14,878 times | 0 comments
I'm moving my Content Management System over to CakePHP 1.3. I'll post an article about my experiences later. Today I will focus on one and only one issue with the migration from Cake 1.2 to 1.3: the change of webroot/theme/ to webroot/theme/ to serve static content. At first I was a little disapointed/scared at the prospects of making this change, but have since come to see the absolute brilliance in this approach.
Read: Global Mysql Find and Replace with CakePHP | View: Comments
Difference Between Truncate and Empty (Delete From) in Mysql
Posted on 06/23/2010 at 02:30 pm | Viewed 33,174 times | 1 comment
I use Navicat for administering all of my MySQL databases. It has a command that I always use- empty table. I noticed today that all along there has been a command right below it for truncate table. Hmmm. I figured this would result in the same outcome and wondered what the difference is between emptying a mysql table and truncating the same table.
Read: Difference Between Truncate and Empty (Delete From) in Mysql | View: Comments
Speeding Up Cakephp's ACL Component
Posted on 05/28/2010 at 12:12 pm | Viewed 18,106 times | 1 comment
I came across a posting today that changed the performance of my application tremendously and reinforced a concept I had forgotten about- mysql indices. I didn't realize my app was running slow until I implemented the mysql indexes below- no formal benchmark testing, but I would say speed improved by about 300%. The improvement was most noticeble when you are building your ACL using the CakePHP suggested method.
Best Free Mysql Zip code Database
Posted on 04/20/2010 at 04:42 pm | Viewed 20,211 times | 0 comments
I'm sure every developer reaches a point when they will need to use a mysql database of zip codes in the United States. Say you want to make a store locator and show how many miles a customer is from your store, or if you have some custom php logic that uses zip codes, you will inevitably need a mysql database of zipcodes.
Controlling CakePHP Error Handling When Debug = 0
Posted on 04/19/2010 at 04:27 pm | Viewed 28,123 times | 1 comment
I finally had a client request a piece of functionality that required me to program CakePHP so I could better control the default error handling when the site is in production mode (i.e. debug is set to 0). By default, CakePHP will throw a 404 page not found header whenever ANY errors occur on a production site with debug equal to zero. This works great, most of the time. But what about when you are having database connectivity issues? Say when there are too many mysql connections to that overloaded shared hosting box? Modifed CakePHP error handling to the rescue.
Read: Controlling CakePHP Error Handling When Debug = 0 | View: Comments
CakePHP Translate Behavior - Lessons Learned
Posted on 12/15/2009 at 08:29 am | Viewed 34,726 times | 5 comments
I've been working on setting up a multi-lingual web site for one of my clients. I was excited at the opportunity to finally use CakePHP's built-in internationalization and locale functions. However, I ran into some issues that I'm sure other newbies to internationaliztion will run into as well. Here's some take-backs of what I learned while using the Translate Behavior in Cake...
Read: CakePHP Translate Behavior - Lessons Learned | View: Comments
Delete Dependent Just Deleted All My Records
Posted on 09/17/2009 at 10:12 am | Viewed 13,511 times | 0 comments
Oh man! I just deleted all my database records using $model->del($id) with dependent=>true in the model association. That wasn't supposed to happen! It turns out to be an issue with how I specified my model association. What's weird is that everything works fine except when I go to do the delete with cascade set to true.
Read: Delete Dependent Just Deleted All My Records | View: Comments
Invalid Date Value Error in MySQL
Posted on 09/09/2009 at 02:26 pm | Viewed 12,783 times | 0 comments
I ran into an interesting issue with valid dates and MySQL on Windows. I wrote a CakePHP import function that basically moves MySQL data from one DB to the other. I never thought that I would see an error related to an invalid date, but I did.
What determines if a date value is invalid (read: warning) or unacceptable (read: error)?
Manually Installing MySQL on Windows 2003 Server
Posted on 09/02/2009 at 12:02 pm | Viewed 12,084 times | 0 comments
I have been trying to install MySQL on a web server running Windows 2003 for quite a while now. I was finally successful! Here's how I did it...
Does your server have a hard-coded IP address?
If so, you need to make localhost refer to the manually assigned IP address in your hosts file. This file is located in C:\Windows\System32\drivers\etc.
Read: Manually Installing MySQL on Windows 2003 Server | View: Comments
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
Read: Using Between with Date Ranges in Proper DB Date Format | View: Comments
Distinct vs. Group By in MySQL (and CakePHP)
Posted on 05/21/2009 at 11:27 am | Viewed 21,716 times | 2 comments
An interesting problem- I am returning a list of files that have already been uploaded, so the user can link to an existing file. This creates a new record (duplicate record). The next time the user goes to select a file, there will now be two entries for the same file. DISTINCT to the rescue, or so I thought.
DISTINCT applies to the whole select statement
Read: Distinct vs. Group By in MySQL (and CakePHP) | View: Comments
Dealing with MySQL Old-Style Passwords
Posted on 05/20/2009 at 04:37 pm | Viewed 12,708 times | 0 comments
I ran into a problem I've seen before- Client does not support authentication protocol requested by server; consider upgrading MySQL client. Last time I came across this MySQL error, it was a simple query to fix the issue (from dev.mysql.com):
UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd') WHERE Host = 'some_host' AND User = 'some_user'; FLUSH PRIVILEGES;
Read: Dealing with MySQL Old-Style Passwords | View: Comments
Full Tag List
- Cakephp
- Web Programming
- Site Avenger
- Excel
- Csv
- Database
- Saveall
- Vendors
- Import
- Truncate
- Empty Table
- Forms
- Habtm
- Usage
- Tinymce
- Geshi
- Usability
- Upgrade
- Graphic Design
- Internet Marketing
- Software
- From The Hip
- Midcoast Magnet
- User Group
- Component
- Mssql
- Git
- Apache
- Seo
- Htaccess
- Mysql
- Eclipse
- Gear
- Photoshop
- Php
- Css
- Iis
- Web Server Admin
- 404 Errors
- Iisreset
- Web Design
- Hack
- Internet Explorer
- Ie
- Firefox
- Forum Answers
- Jquery
- Swfupload
- Windows
- Example
- Links
- Tutorial
- Errors
- Behaviors
- Cakephp 13
- Humor
- Music
- Jquery Ui
- Ui
- Wamp
- Cloudfiles
- Setup
- Javascript
- Responsive
- Quick Tip
- Cake3
- Foundation
- Google Tag Manager