Welcome to MainelyDesign.com

Photos of Rockland, Maine. Summer 2009.

A blog mostly about web design

This is the personal blog of Kevin Wentworth.  Topics covered here are web programming, design and internet marketing.

Global Mysql Find and Replace with CakePHP

Posted 3 days, 9 hours ago | Viewed 26 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/themed/ 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.

Difference Between Truncate and Empty (Delete From) in Mysql

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

Best Approach to Dynamic Javascript in CakePHP Views

Posted on 05/29/2010 at 12:36 pm | Viewed 570 times | 0 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 the header, which is where most javascript should live.  The best approach to adding dynamic javascript to your CakePHP views is to implement PHP's output buffering, combined with $View->addScript().

Speeding Up Cakephp's ACL Component

Posted on 05/28/2010 at 12:12 pm | Viewed 486 times | 0 comments

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 568 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 1,326 times | 0 comments

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.

Cache Results from Query in CakePHP

Posted on 03/24/2010 at 11:18 am | Viewed 734 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 the duration of the page load.  If you want to cache query results to the file system, listen to Miles.

Setting Envelope-From in CakePHP's Email Component

Posted on 03/22/2010 at 05:56 pm | Viewed 872 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 = 'email@domain.com';  You have to use an as yet undocumented feature... $this->Email->additionalParams;

2 Neat Little PHP Tricks

Posted on 03/16/2010 at 04:15 pm | Viewed 756 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 Function to Validate Bank Routing Numbers

Posted on 03/16/2010 at 04:10 pm | Viewed 695 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:

Use a Plugin Element Outside of the Plugin in CakePHP

Posted on 03/13/2010 at 01:03 pm | Viewed 653 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 app-wide elements or themed elements folder.

Create a Checklist Group or Related Checkboxes in CakePHP

Posted on 03/05/2010 at 12:38 pm | Viewed 951 times | 0 comments

This is an interesting one.  I needed to create a group of checkboxes.  In my mind, it's just like a radio button group, except with checkboxes.  The only difference should be that with radio buttons you can only select one, while with a checkbox group you should be able to select as many as you want.  To achieve a checklist group in CakePHP is a little convoluted.

Export to PDF from Microsoft Publisher

Posted on 03/05/2010 at 10:54 am | Viewed 427 times | 0 comments

I have a client that sends me newsletters in Microsoft Publisher format.  I wanted to output the newsletter as a PDF, but wanted to keep the text for SEO and so users can copy and paste the text if needed.  Microsoft Publisher doesn't have an export to PDF function, so usually I would just do a File > Print and select Adobe PDF as the printer.  However, this would just be an "image" of the document, not the actual document with selectable text.  This is how you can get a PDF with rendered text out of Microsoft Publisher...

Which Submit Button was Clicked in CakePHP? Use Name.

Posted on 03/04/2010 at 12:01 pm | Viewed 952 times | 1 comment

If you want to have multiple submit buttons that make a form do different things there's a simple way to do this.  The name of the submit button that was clicked by the user will be sent (via POST) with all the other POSTed data.  This is very handy if you want to have a cancel button and continue button. In CakePHP the name of the button won't be in $this->data, but it's easy enough to get...

PHP Break Out of All Foreach or While Loops

Posted on 02/25/2010 at 02:44 pm | Viewed 610 times | 0 comments

Let's have some fun with PHP's break command... I didn't think it was possible.  I just learned (I've been programming PHP for like 7 years) that you can instruct break how many levels of nesting to break out of!  I'm not surprised that break in PHP allows you to specify the number of loops (or switch statements) to break out of, but I am surprised it took me this long to use it!

Changing the Order Sequence of CakePHP Behaviors

Posted on 02/25/2010 at 07:20 am | Viewed 477 times | 0 comments

For reasons too long to explain in this post, I have two behaviors that are run on the same pieces of data (a translate behavior and a settings import/export behavior).  One behavior is attached to the model using var $actsAs, while the other behavior is attached dynamically, during runtime using $this->attachBehavior();.  I needed the "hardcoded" behavior to run after the dynamically attached behavior.  Here's what I did:

Getting a List of Database Tables in CakePHP

Posted on 02/23/2010 at 12:22 pm | Viewed 629 times | 0 comments

I ran into an interesting problem today.  What I wanted to do was know if a table didn't exist in my CakePHP application.  What happens- a cakeError is thrown everytime a database table doesn't exist.  This is really annoying...I think it would be beneficial to be able to tell Controller::loadModel() to return false instead of an error message.  That's not the case.  Here's how I got around it (with thanks to Miles Johnson):

Best CSS Method for Using Image as Submit Button

Posted on 02/03/2010 at 12:17 pm | Viewed 797 times | 2 comments

I came across an interesting issue with web forms and CSS.  Surprisingly, the end result is much better than I expected.  I knew that using an image instead of a traditional form submit button (<input type="submit">; instead of <input type="image"> or <input type="button">) would be a little challenging.  I like a challenge, plus I wanted to use the submit button because it's the standard approach to forms and I remember reading somewhere that input's of type image or button do not submit when you press enter...a usability faux paus in my opionion.

Weird Git Error After Upgrade: Repository not found. Make sure you include the .git

Posted on 02/02/2010 at 08:18 am | Viewed 503 times | 0 comments

This isn't a weird error in that I've never seen it (ususally when I forget to load up Pagaent before attempting Github push/pulls).  It's weird because everything was working perfectly and then I couldn't do anything from remote!  I upgraded msysgit recently and hadn't tried to do any remote commands until yesterday.  And I kept getting the following error in Git Gui:

Using Git and Plink for SSH on Windows

Posted on 01/25/2010 at 11:11 am | Viewed 915 times | 0 comments

Well, I finally had an opportunity to install Git on Windows yet again.  It had been quite a while since my last time installing Git on Windows, so I was a little rusty and couldn't figure out how to get Git to use Plink for SSH.  It's actually quite simple and dependent on a Windows system variable.

Using Jquery for target="_blank" and strict xHTML

Posted on 12/28/2009 at 03:27 pm | Viewed 834 times | 0 comments

If you like to see the little green check mark that HTML Validator shows when your HTML is 100% valid, you'll love this little trick. Thanks to badlydrawntoy.com

12 Essential Photoshop Keyboard Shortcuts

Posted on 12/21/2009 at 05:05 pm | Viewed 693 times | 0 comments

I remember about 7 years ago watching my friend use Adobe Illustrator.  He was a communications design major and used his keyboard more than his mouse.  I was blown away when I realized how much time you could save by learning keyboard shortcuts for Adobe's products.  This is my list of the best Adobe Photoshop keyboard shortcuts for web designers.

CSS Min-Height Hack in Internet Explorer

Posted on 12/15/2009 at 10:18 am | Viewed 770 times | 0 comments

Another day of web developing with CSS and another day of needing a hack for IE6 and IE7.  This isn't really a hack so much as it's a method of ordering statements in your CSS declaration that yields a working min-height declaration in Internet Explorer.  Well, I guess it's a hack (but I hate using them).

CakePHP Translate Behavior - Lessons Learned

Posted on 12/15/2009 at 08:29 am | Viewed 1,519 times | 4 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...

Upgrading Jquery UI Tabs and it Stopped Working

Posted on 12/09/2009 at 08:16 pm | Viewed 734 times | 0 comments

I was upgrading the version of Jquery UI that I use with Site Avenger.  The last time I was in a rush, nothing seemed to work and I rolled the changes back.  This time, I took the time and decided to finally make this Jquery UI upgrade happen.  This time everything went swell, except my Jquery UI tabs plugin stopped working.  WTF?

Viewing Rendered Email Messages in CakePHP

Posted on 12/09/2009 at 12:15 pm | Viewed 879 times | 1 comment

For a while it's bugged me that I wasn't able to see the rendered output of my email messages that are sent using the CakePHP email component. I would change my code to use a remote smtp server but I still had to send messages.  Well, I finally figured out how to "debug" my emails sent using CakePHP.  Thanks to this posting for finally putting all the pieces together...

Cool Stuff with CakePHP: Cryptable Behavior

Posted on 11/20/2009 at 11:19 am | Viewed 637 times | 0 comments

There is so much cool stuff out there that's already been done with CakePHP.  In an attempt to catalog it for my own use later, I'm going to start creating blog posts that highlight cool behaviors, components, etc. for CakePHP.  This is the first one.

Jquery Accordion Menu - Expanding UL Menu

Posted on 11/17/2009 at 01:25 pm | Viewed 2,260 times | 0 comments

I looked around and found some interesting examples and existing plugins for creating an accordion menu in Jquery.  What I was looking for was a nested unordered list (UL) that would collapse and expand based on which menu item was clicked.  If there wasn't a child UL, then the menu link should be clickable, instead of an accordion.  Sounds simple right?

Jquery Direct Descendant Selector (using the >)

Posted on 11/17/2009 at 01:08 pm | Viewed 431 times | 0 comments

I'd been struggling with a very simple accordion menu script.  The problem was that I couldn't stop all of the links from returning false, when I only wanted to top link to return false.  Let me show you my code:

Auto Columns with Columnizer - My New Favorite Jquery Plugin

Posted on 09/30/2009 at 10:37 am | Viewed 1,872 times | 0 comments

I was about to start coding a CakePHP helper that would analyze a bulleted list and split it into columns.  Starting to think about how I would approach this problem, my head began to hurt.  Then I found an awesome jQuery plugin- columnizer.

CSS Small-Caps Working in IE Not in Firefox

Posted on 09/24/2009 at 11:03 am | Viewed 765 times | 0 comments

Another IE/FF Inconsistancy?

A Really Good Implementation of Captcha

Posted on 09/22/2009 at 02:45 pm | Viewed 547 times | 0 comments

Awesome Captcha Implementation

Faking Symlinks on Windows 2003

Posted on 09/17/2009 at 04:25 pm | Viewed 720 times | 0 comments

My production server is a LAMP server.  I love it.  I have one cental location for my CakePHP application and symlink the folders I need to each individual hosting account.  It's pretty easy to do and very powerful.  I work on another server that is Windows 2003.  Everytime I sit down to do work, I bemoan not having the ability to create symlinks.  Turns out there is a way...

Delete Dependent Just Deleted All My Records

Posted on 09/17/2009 at 10:12 am | Viewed 617 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.

Date Input Using Cakephp Form Helper

Posted on 09/09/2009 at 03:29 pm | Viewed 3,194 times | 2 comments

I always forget what exactly needs to happen in order for CakePHP's form helper to work with date input fields.  I'm sick of tearing through old source code and looking at the official CakePHP docementation site.  Here's how to get it to work...

Invalid Date Value Error in MySQL

Posted on 09/09/2009 at 02:26 pm | Viewed 542 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.

Cakephp's Flay Class is Amazing - Examples Included

Posted on 09/08/2009 at 09:31 pm | Viewed 956 times | 0 comments

If you haven't checked out CakePHP's Flay class, check it out. It's one of the best utility classes for text output in CakePHP.

Manually Installing MySQL on Windows 2003 Server

Posted on 09/02/2009 at 12:02 pm | Viewed 549 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...

Using Exif in PHP on Windows

Posted on 08/28/2009 at 09:40 am | Viewed 550 times | 0 comments

I'm trying to use the exif functions in PHP on my Windows XP computer.  I want to read the meta data that is recorded by my digital camera (exif - exchangeable image file format).  I like the idea of storing that exif data in the database, so it's searchable. I wasn't having any luck with exif_read_data(), but finally found this posting.

Making Valid Email (mailto) links in CakePHP

Posted on 08/25/2009 at 04:59 pm | Viewed 796 times | 0 comments

It's easy to make an email address using the HTML's helper link() function.  All you need to do is have an email address appended with the string 'mailto:' (just like in regular ol' HTML).

Changing Filetypes Shown in SWF Upload File Browser

Posted on 08/25/2009 at 04:17 pm | Viewed 675 times | 0 comments

It's easy to change which file types are allowed to show up (and are displayed) when you browse for files to upload through SWF Upload.  SWF Upload makes it easy to upload multiple files in PHP.

Network Solutions' Flawed .htaccess and Mod_Rewrite Rules Implementation

Posted on 08/06/2009 at 02:38 pm | Viewed 1,571 times | 1 comment

I can't believe it!  I spent hours trying to get the mod_rewrite rules working in .htaccess on Network Solutions' servers.  Everything I tried didn't work.  Using the default .htaccess (from Cake distribution) failed.  I've used the distribution on several servers and never had any issue with the rewrite rules.  However, Network Solutions's mod_rewrite works differently than [all] other servers.

Cheatsheet for Creating .MOV Files from .VOB files (DVDs)

Posted on 07/30/2009 at 11:38 am | Viewed 529 times | 0 comments

Every now and again I need to take a video from a promotional DVD and put it on a client's web site.  I use a handy utility that will convert almost any video file into a flash video (.swf/.flv).  The hard part usually comes from having to rip the video from the DVD. 

TinyMCE Doesn't Work in IE8

Posted on 07/24/2009 at 11:54 am | Viewed 1,647 times | 2 comments

I was training a client how to update their web site using Site Avenger when the strangest thing happened- no copy was showing in TinyMCE.  No matter what I pasted the tiny editor would remain a nice, plain white.  I didn't think to try typing directly into TinyMCE.  No matter, a click on the HTML button to view the source revealed the content was in fact there, just not being shown within the TinyMCE editor.

Phantom Whitespace Below Img in Firefox

Posted on 07/22/2009 at 10:24 am | Viewed 737 times | 0 comments

I've come across this thing a few times before- there's a strange space below images in Firefox, but not in IE.  I finally found a nice explanation as to why it happens, which I wanted to post here.

Faking min-width CSS style in IE6 and IE7

Posted on 07/16/2009 at 01:50 pm | Viewed 547 times | 0 comments

It's a hack... but it's needed to make a truly cross-browser fluid layout.  It's simple, if you want to implement min-width in IE6 and IE7, use the following CSS code: (I didn't create this originally, sorry, lost the source)

Avoiding Flash (.flv) 404 Errors on IIS 6 (Windows 2003)

Posted on 07/15/2009 at 11:11 am | Viewed 936 times | 1 comment

An interesting thing happens on Windows 2003 Server (IIS 6) when you try and play a .flv file through an embedded shockwave player...nothing.  Well, actually you get a 404 error. 

Using Between with Date Ranges in Proper DB Date Format

Posted on 07/09/2009 at 11:56 am | Viewed 1,496 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.

Adding Anchors to Your CakePHP Generated Urls (#link)

Posted on 07/02/2009 at 09:02 am | Viewed 2,340 times | 2 comments

This may seem simple and trivial, but it took me a little while to figure out.  If it saves someone a little trial-and-error then great (I know I won't forget how to do it).

Using CakePHP's Set Class to Make Select List Options

Posted on 06/19/2009 at 11:22 am | Viewed 950 times | 0 comments

If you haven't become familar with any of the functionality of the CakePHP's Set class, I highly recommend you take a peak.  I don't know too much about it and really only learn about it as I go.  Well, I finally found out how to do something that used to take several lines of code: creating options for a select list that includes the Model.id as the key, but has a concatenated string for the value, like 'Model.name - created by Model.userName'.

Changing the CakePHP Model Schema on the Fly

Posted on 06/11/2009 at 10:28 am | Viewed 1,038 times | 0 comments

I have an interesting way of dynamically changing a model's validation on the fly.  I have a standard approach that involves contact forms, contest entries, etc. using a database to store which fields should be on a form.  I tweaked this over time, and recently needed to change the schema from text, which all answers have been up to this point (and IS the DB field type), to a type of date. I kept getting the error 'preg_replace expects parameter 2 to be a string, array given'.  Once I got the right schema, the errors went away.

Displaying phpinfo() without CSS styles

Posted on 06/09/2009 at 10:18 am | Viewed 837 times | 1 comment

I wanted logged in users to be able to see the output from phpinfo(); within Site Avenger.  The problem with using phpinfo() is that it outputs a full HTML page, CSS styles and all.  In the past this has been fine, but now I wanted to show the phpinfo() within the Site Avenger layout and CSS styles.  I came across a simple, yet highly effective solution...

Getting the File Path to the Vendor Folder

Posted on 06/08/2009 at 04:47 pm | Viewed 594 times | 0 comments

I'm trying to use a library within my CakePHP application that needs a variable defined that contains the complete file path to the vendors folder.  This can be solved one of two ways- modify the library (which I don't want to do) or use the Configure::corePaths() function in CakePHP.

Fixing the Default HP OfficeJet Scanner Settings (which suck)

Posted on 05/28/2009 at 11:11 pm | Viewed 629 times | 0 comments

The default settings for my OfficeJet L7500 All-In-One Scanner suck!  I thought the scanner was junk.  Every photo I scanned, espcially glossy finished photos, were coming out looking like they were from a 1960s era camera: over-exposed and super high contrast.  Not good!  I thought I had good Photoshop skills, but even they were no match for the over-exposed mess that HP was sending into Photoshop.

Distinct vs. Group By in MySQL (and CakePHP)

Posted on 05/21/2009 at 11:27 am | Viewed 1,981 times | 1 comment

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.

Best Eclipse Feature: Link With Editor

Posted on 05/21/2009 at 09:43 am | Viewed 621 times | 0 comments

I use Eclipse for all of my CakePHP development work.  I love that you can get code completion, class inheritance, and more by following these steps.  I also loved that I could have 20 something files opened, and when I changed the active document in the editor, my PHP Explorer hierarchy would change in response. 

Dealing with MySQL Old-Style Passwords

Posted on 05/20/2009 at 04:37 pm | Viewed 743 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):

Changing Display Options in Model::find('list')

Posted on 05/19/2009 at 10:49 am | Viewed 596 times | 0 comments

I wanted to change the displayed field that Cake automatically returns with a Model::find('list').  If you have a database column named title or name (I'm not sure of the full list), CakePHP will automatically return an array index by Model.id => Model.name.  This usually works, but today I'm working with a database table that doesn't use that field- it's a table of uploaded files and uses the columns named 'src' or 'alt' to display information to the user.  I forgot how to do this, so I'm posting it for reference.

Getting the CakePHP Version in Your Code

Posted on 05/14/2009 at 10:57 am | Viewed 892 times | 0 comments

I was sick and tired of having to FTP into my accounts and view the VERSION.txt file that comes with the Cake core to figure out what version of Cake I was running.  I did a quick search but wasn't finding anything.  I was about to dig in and hack something together, but tried the CakePHP API as a last resort. Bingo!

Naming a Text File .htaccess on Windows

Posted on 05/13/2009 at 12:15 pm | Viewed 552 times | 0 comments

A big pain- you can't just name a file .htaccess through Windows Explorer.  It complains that you need to supply a name!  No problem.

Making Apache Parse .html files as .php Files

Posted on 05/13/2009 at 12:09 pm | Viewed 620 times | 0 comments

When re-designing a site, or somehow being locked into a given web site structure that uses .html (or .htm) file extensions, it's a good idea to keep the file names the same (especially if the site has been around a while and has good search engine visibility).  Think you can't use PHP on .html or .htm web pages?  Think again.  With apache it's as easy as modifying the .htaccess file.

Keep Old Settings When Upgrading Eclipse

Posted on 05/12/2009 at 01:02 pm | Viewed 606 times | 0 comments

I decided to upgrade my version of Eclipse to 3.4 (Ganymede) mainly so I could use the Git plugin.  I wanted to migrate my settings from one install to the other.  I know I had done this before, when I upgraded from 3.2 to 3.3, but forgot how.  So I don't have to scratch my head so much next time, here is how you can move your settings after you upgrade your version of Eclipse.

Avoiding New Line Errors using Git on Windows

Posted on 05/12/2009 at 12:27 pm | Viewed 820 times | 0 comments

I'm finally working on moving my code over to a version control system.  I've tried several times over the past few years to start using Subversion, but I never quite got into it.  After hearing so much about Git, I decided I needed to start using it.  Luckily, most people tell you to forget everything about Subversion when using Git- no problem there!

Pagination with MSSQL in CakePHP

Posted on 05/07/2009 at 04:36 pm | Viewed 1,150 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.

From the Hip - Midcoast Maine User Group

Posted on 05/07/2009 at 11:23 am | Viewed 546 times | 0 comments

Well, it finally happened! The Midcoast has a web design/interface design user group.  Last night was the first meeting of From the Hip, an informal, agendas-not-allowed, information exchange session.  Some people from Midcoast Magnet helped organize the event, and now the group finally has legs!

A tale of caution: naming CakePHP "view" functions

Posted on 05/06/2009 at 05:13 pm | Viewed 1,433 times | 0 comments

Spoiler: functions that generate a view must be named using lower_case_with_underscores()

Getting Full Resolution Pictures out of MS Word (almost)

Posted on 04/29/2009 at 11:14 am | Viewed 976 times | 1 comment

People use what they know.  Most of the time I get photos embedded in an MS Word document for use on a web site.  My workaround to date has been to enlarge the picture (in Word) until it is as big as it gets (keeping quality) or the size I need.  I would then do a print screen and paste into Photoshop. 

Best Tiny Font for Web Graphics

Posted on 04/28/2009 at 05:03 pm | Viewed 1,318 times | 0 comments

I finally found the perfect font for making really small, yet readable text in web graphics.  I've played around with plenty of fonts and usually arrive at a reasonable result.  In the past I would use Eurostyle with enough spacing to make it legible.  Now, I have a new go-to font for small typeface.  Introducing Silkscreen.

Preformatted Text in TinyMCE <pre></pre>

Posted on 04/21/2009 at 10:26 am | Viewed 2,352 times | 0 comments

Now that I've got my blog up and running, I've been playing around with syntax highlighting of source code.  I really appreciate sites that serve up code samples in a nice format, so I've tried to comply with my own version of this best practice.

$paginator->sort() error?

Posted on 04/17/2009 at 01:32 pm | Viewed 856 times | 0 comments

I thought there was an error in the paginator view helper.  All of a sudden I could only sort a field ascending.  I (again) did a little research and came across a great thread on the CakePHP Google Group (here).  Basically, as of 1.2.8120, you need (or should) specify the ModelName in your sort() function.  I had only been doing sort('id'), sort('name').  Now I am doing sort('ID', 'ModelName.id') and sort('Name', 'ModelName.name').  It's a little more work having to specify the label (otherwise it defaults to ModelName.field, instead of just field).

Transactional Support in CakePHP

Posted on 04/17/2009 at 11:50 am | Viewed 1,033 times | 0 comments

I just found out that CakePHP has transactional support built-in.  It should have been obvious, seeing how the saveAll() function has transaction support built-in too.  My first attempt at using it didn't work.  In my contoller/model I was doing the following:

saveAll() to save multiple records in 1 model

Posted on 04/17/2009 at 09:58 am | Viewed 877 times | 0 comments

I ran into another issue on something I thought would be simple: saving multiple records with the saveAll() command.  In case you don't know about it, saveAll() is one of the best functions in CakePHP.  It automatically supports transactions, HABTM saves, and certainly saves a lot of typing for almost every type of save you want to do.

Checkbox - setting the default state

Posted on 04/17/2009 at 08:31 am | Viewed 863 times | 0 comments

I ran across a rather simple problem (I thought) that took a little searching to figure out.  All I had to do was create a checkbox form input that I wanted to have checked by default.  I tried 'default'=>'checked', which didn't work.  I also tried 'checked'=>true and 'checked'=>1, but that works every time, even if validation fails and the user had unchecked the checkbox, it will be checked again (Not good usability). 

Importing an Excel file into CakePHP

Posted on 04/16/2009 at 02:42 pm | Viewed 2,517 times | 0 comments

I needed to be able to upload an excel file, parse the file, and then add each row as a separate database entry.  I had this working for a CSV file using the php built-in function fgetcsv(), but the client switched to using an excel file (instead of direct PHP access to the in-house database, we decided to have the client upload a CSV/Excel file). 

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design