MainelyDesign.com Blog

Cakephp Tagged Blog Posts

Making PHP File Uploads Work For Large Files

Posted on 06/18/2013 at 01:01 pm | Viewed 8,251 times | 0 comments

Get PHP File Uploads Working

The first trick to having any user contributed content these days is to get PHP File Uploads working (especially with big files).  Our configuration we use for our Wamp local development and on our Linux server is below.

When managing file uploads to a server, there seems to be a lot of confusion regarding optimized PHP settings and configuration. We have had some experience with this that we would like to share.

Speeding Up Windows 8 for Web Development (using WAMP)

Posted on 02/25/2013 at 01:33 pm | Viewed 42,233 times | 0 comments

Here is my list of optimizations and changes you can make (and I've had to make) in order to get WAMP (and CakePHP) to run faster on my Windows 8 computer.

Speed Up WAMP Web Development on Windows 8

The short list, in order of importance (stop once you are happy with your localhost web server response time and speed):

  • Get the latest version of WAMP.
    Start by downloading the latest wamp.  I used the 64 bit version.  Download WAMP here.

  • Edit your hosts file.
    Make sure it has the proper entries, and most importantly, remove the IPv6 localhost setting.  Your Windows 8 hosts file should look like this:

    127.0.0.1          localhost
    #    ::1             localhost

  • Disable IP v6
    A great tutorial can be found here.  My advice is to disable IPv6 BOTH ways- via the network adapter and via the regedit hack.

  • Edit Apahce httpd.conf
    These tweaks are supposed to speed up the lstat() system calls when reading files/scanning directories.  They are:

    EnableMMAP On
    EnableSendfile On

  • Edit PHP.ini
    Increase the real path cache size.  This helps when you have lots of files involved.

    ; Determines the size of the realpath cache to be used by PHP. This value should
    ; be increased on systems where PHP opens many files to reflect the quantity of
    ; the file operations performed.
    ; http://php.net/realpath-cache-size
    realpath_cache_size = 24M

  • CakePHP: make sure debug is off.

Avoiding Errors with Zend Lucene Search Results

Posted on 01/14/2013 at 02:34 pm | Viewed 11,910 times | 0 comments

A common, recurring headache and complaint among Zend Lucene search processing is handling the data fields in search results.

We all like to be flexible and robust in handling the results, we may want our search to return news articles, blogs or webpage content.  

Invariably,  we run into problems, usually in the form of an exception

CakePHP Form Security Blackhole on Large Forms

Posted on 06/28/2012 at 11:11 am | Viewed 9,904 times | 0 comments

I kept getting the White Screen of Death (WSOD).  What we at Saco Design have appropriately named the behavior of the default blackhole Security Component setting.  The weird issue was that I was getting the issue only on the live server.  I had recently updated the live server's version of PHP to the latest 5.3.x release.  However, I neglected to update my local PHP version, which was still 5.3.5. 

Calling an Element from a Helper

Posted on 02/24/2012 at 02:07 pm | Viewed 8,362 times | 0 comments

This one caused me more than a little headache,  turned out it was easily solvable.

renderElement() can be used in a helper function.

The following example worked nicely for me.

In this case I am calling and element "order_form.ctp"

 

$theView = ClassRegistry::getObject('view');

Forcing A Single Join in CakePHP Pagination

Posted on 10/14/2011 at 09:25 am | Viewed 16,008 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 9,953 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

Best PaginateCount for CakePHP - with Group By Support

Posted on 08/07/2011 at 05:03 pm | Viewed 13,693 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...

CakePHP Error Messages Not Showing on Form

Posted on 04/03/2011 at 12:40 pm | Viewed 14,723 times | 2 comments

I ran into an issue today that I've run into before, except I couldn't remember what I did to fix it (hence this article).  I was using CakePHP validation rules to validate a user account details.  The CakePHP validation was properly failing (the form data wasn't being saved) and I could tell the validate array was set correctly because the required fields were having the class .required added to them.  The only problem?  No error messages were being output to the form.  The form validation would fail, but the CakePHP error messages were not being shown.

Sorting Paginated Results Using a Related Model Field in CakePHP

Posted on 02/06/2011 at 10:12 pm | Viewed 13,885 times | 0 comments

Time crunch, so this will be quick.  I didn't want to go hunting for how to sort paginated results in CakePHP using a related model field again.  I actually found my answer on Stack Overflow.  The original poster had it right, so I'm not sure if it was a CakePHP bug or what (I don't have an account or I would correct it... it's on the list of to-dos though).

Changing CakePHP's Model useTable on the Fly

Posted on 11/02/2010 at 05:12 pm | Viewed 12,564 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

The Funniest Error Message Ever - Thank You Eclipse

Posted on 10/18/2010 at 06:34 pm | Viewed 10,264 times | 0 comments

In a depature from my [normally] on-topic (i.e. dry) posts I had to post this error message up here. It made me laugh! I was working on the fattest CakePHP controller known to man (over 4,000 lines, I know... not skinny) when Eclipse ran into issues.  Eclipse gave a very descriptive error message, stating that it couldn't, well see for yourself:

Upgrading CakePHP Application to 1.3 (from 1.2)

Posted on 09/27/2010 at 09:33 pm | Viewed 10,086 times | 2 comments

I've been waiting to publish a completed article until after I was done with my upgrade to CakePHP 1.3.  Well, it's taking a while.  I'm not blaming the CakePHP upgrade from 1.2 to 1.3 for taking so long.  I'm actually doing several large-scale changes to my code base, my server and my repository structure.  Until that time, I'm going to publish some notes I've been making for this article.

Getting All ACL Permissions in One Lookup (CakePHP 1.3)

Posted on 09/19/2010 at 11:36 am | Viewed 15,662 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. 

CakePHP 1.3 Improvements Over CakePHP 1.2

Posted on 09/09/2010 at 02:01 pm | Viewed 9,659 times | 0 comments

I've been working on upgrading my CakePHP application to cake version 1.3.  It's a lot of work.  I find myself constantly consulting the CakePHP manual/book for answers.  There are many places to look for all of the improvements that were rolled into CakePHP 1.3 (at least coming from the 1.2 version).  For my own reference, I'm creating a list of all of the manual pages that reference improvements, new features and/or different ways of doing things in CakePHP 1.3.

Global Mysql Find and Replace with CakePHP

Posted on 08/31/2010 at 09:03 am | Viewed 9,316 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.

Best Approach to Dynamic Javascript in CakePHP Views

Posted on 05/29/2010 at 12:36 pm | Viewed 16,746 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 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 12,622 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.

Controlling CakePHP Error Handling When Debug = 0

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

Cache Results from Query in CakePHP

Posted on 03/24/2010 at 11:18 am | Viewed 10,024 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 11,954 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;

Use a Plugin Element Outside of the Plugin in CakePHP

Posted on 03/13/2010 at 01:03 pm | Viewed 10,247 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 35,765 times | 1 comment

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.

Which Submit Button was Clicked in CakePHP? Use Name.

Posted on 03/04/2010 at 12:01 pm | Viewed 19,611 times | 2 comments

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...

Changing the Order Sequence of CakePHP Behaviors

Posted on 02/25/2010 at 07:20 am | Viewed 8,518 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 12,712 times | 1 comment

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):

CakePHP Translate Behavior - Lessons Learned

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

Viewing Rendered Email Messages in CakePHP

Posted on 12/09/2009 at 12:15 pm | Viewed 15,849 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 8,298 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.

From the Bakery: "A behavior that will automatically encrypt/decrypt specified fields in a model, using your choice of cipher, key, and IV."

Faking Symlinks on Windows 2003

Posted on 09/17/2009 at 04:25 pm | Viewed 11,932 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 9,161 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 26,828 times | 3 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...

Date Inputs Using the Form Helper:

$current_year = date('Y');
$max_year = $current_year + 2;
echo $form->input('dateSelectBoxes', array('type'=>'date', 'selected'=>$unix_timestamp, 'empty'=>true, 'minYear'=>2009, 'maxYear'=>$max_year));

Invalid Date Value Error in MySQL

Posted on 09/09/2009 at 02:26 pm | Viewed 8,446 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)?

Cakephp's Flay Class is Amazing - Examples Included

Posted on 09/08/2009 at 09:31 pm | Viewed 9,481 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.

I just noticed that my blog was using the same META description for all of my blog entries- not good for SEO.  Instead, I want to pull a fragment of the article copy and use that as my META description.  I currently use this convoluted way to get my summaries from the article copy, so I decided to try using the Flay class.  I've used it before but I'm glad I revisited it... it's amazing!

Making Valid Email (mailto) links in CakePHP

Posted on 08/25/2009 at 04:59 pm | Viewed 10,689 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).

Here's my quick and dirty function to attach it if it doesn't exist:

if(stristr($image['link'], '@') and stristr($image['link'], 'mailto') === false) {
	$address = 'mailto:'. $image['link'];
} else {
	$address = $image['link'];
}

echo '<p>'. $html->link($image['link'], $address) . '</p>';

Network Solutions' Flawed .htaccess and Mod_Rewrite Rules Implementation

Posted on 08/06/2009 at 02:38 pm | Viewed 26,586 times | 7 comments

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.

Using Between with Date Ranges in Proper DB Date Format

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

Adding Anchors to Your CakePHP Generated Urls (#link)

Posted on 07/02/2009 at 09:02 am | Viewed 26,875 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).

I needed to create a redirect in CakePHP that redirected to an inline, on-page anchor- <a name="destination">Scroll to Here</a>.  Typing the link directly into the address bar of the browser, it would need to look like this: http://www.mainelydesign.com/blog/view/1219/#destination.  The #destination is what I needed to figure out how to append to the redirected url.  Turns out it was easy...

Using CakePHP's Set Class to Make Select List Options

Posted on 06/19/2009 at 11:22 am | Viewed 9,315 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 9,981 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 14,258 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 9,019 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.

Best Option - using Configure::corePaths()

Distinct vs. Group By in MySQL (and CakePHP)

Posted on 05/21/2009 at 11:27 am | Viewed 14,916 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

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

Posted on 05/19/2009 at 10:49 am | Viewed 8,373 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 12,987 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!

Pagination with MSSQL in CakePHP

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

A tale of caution: naming CakePHP "view" functions

Posted on 05/06/2009 at 05:13 pm | Viewed 9,469 times | 2 comments

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

I just ran into a very interesting problem.  I was testing out some of my plugins to make sure they were still working with Cake version 1.2.2.8120.  They worked fine except for one function.  I had a form that updates a shopping cart, changing the quantities of products placed in the cart.  When I hit the submit button to change the quantities, I was getting redirected to my site root. 

$paginator->sort() error?

Posted on 04/17/2009 at 01:32 pm | Viewed 7,477 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 9,214 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:

$this->Model->begin();
if(!$this->Model->save($this->data)) {
	$this->Model->rollback();
} else {
	$this->Model->commit();
}

saveAll() to save multiple records in 1 model

Posted on 04/17/2009 at 09:58 am | Viewed 11,943 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 10,058 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 23,690 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). 

Full Tag List

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design