MainelyDesign.com Blog

Showing articles 71 - 80 (147 total)

Difference Between Truncate and Empty (Delete From) in Mysql

Posted on 06/23/2010 at 02:30 pm | Viewed 33,292 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...

Best Approach to Dynamic Javascript in CakePHP Views

Posted on 05/29/2010 at 12:36 pm | Viewed 23,318 times | 5 comments

I always knew in the back of my mind that there was a better way of creating dynamic javascript than the method I was using.  CakePHP has a great function as part of the $View controller:  $View->addScript($jscript, false) will add a script block to your template header.  This is the command I use to send javascript created in a Cake view up to...

Speeding Up Cakephp's ACL Component

Posted on 05/28/2010 at 12:12 pm | Viewed 18,172 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...

Best Free Mysql Zip code Database

Posted on 04/20/2010 at 04:42 pm | Viewed 20,278 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.  The Best Free Mysql...

Controlling CakePHP Error Handling When Debug = 0

Posted on 04/19/2010 at 04:27 pm | Viewed 28,201 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...

Cache Results from Query in CakePHP

Posted on 03/24/2010 at 11:18 am | Viewed 15,411 times | 0 comments

I have a HUGE query that I wanted to cache.  I love CakePHP's caching functionality out of the box, but one thing is missing- you can't cache the results of a query.  Let me clarify.  You can cache the reults of a query, but only for that instance of a page load.  Using $this->cacheQueries only caches the query to memory, which only lasts for...

Setting Envelope-From in CakePHP's Email Component

Posted on 03/22/2010 at 05:56 pm | Viewed 18,043 times | 1 comment

I've setup a form that allows customers to sign up for an email newsletter and receive a coupon. I wanted to be able to track the bounced messages in case a legitimate customer's coupon was bounced for whatever reason. As I've learned, setting up the "return-path" for an email message isn't as simple as setting $this->Email->return =...

2 Neat Little PHP Tricks

Posted on 03/16/2010 at 04:15 pm | Viewed 12,677 times | 0 comments

In writing a function to validate bank routing numbers , I came across two simple techniques, that I know I will need to use again: PHP Trick 1: Remove All Characters Except Numbers from a String A simple little regex does the trick: $routingNumber = preg_replace('[\D]', '', $routingNumber); PHP Trick 2: Loop Through a String Character by...

PHP Function to Validate Bank Routing Numbers

Posted on 03/16/2010 at 04:10 pm | Viewed 22,473 times | 0 comments

I needed to validate that a Bank Routing Number was valid, much like the algorithms out there to check if a Credit Card number is valid.  I did a little searching and didn't find a PHP function that would do the trick.  I decided to write my own, based on this javascript function , and publish it for anyone who wants to use it: Function to...

Use a Plugin Element Outside of the Plugin in CakePHP

Posted on 03/13/2010 at 01:03 pm | Viewed 15,061 times | 0 comments

Quick note- I had an element .ctp file that was part of a plugin.  I wanted to render that element across my entire Site Avenger site, including non-plugin layouts and themes.  I found out that you can send $this->element() (formerly $this->renderElement()) a 'plugin' parameter to accomplish this... otherise CakePHP will only look in the...

    4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12   

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design