Before the_post_thumbnail was available, here is how I would fetch an array of images that were attached to a post in wordpress:
More…
RECENT TUNES
- Relaxing Instrumental Music - Rain On The Pond
- Britney Spears - Do Something
- of Montreal - Touched Something's Hollow
- Ryan Cabrera - Let's Take Our Time
- Dr. Dre - Bad Intentions (feat. Knock-turn'al)
- Imogen Heap - Hide and Seek
- Felix da Housecat - Ladytron - Playgirl (Felix Da Housecat Glitz Clubhead Mix)
- Hot Hot Heat - Oh, Goddamnit
- Daft Punk - One More Time
- The Flaming Lips - Mr. Ambulance Driver
PHP Articles
February 12, 2010 – 6:11pm Wordpress get post images and the_post_thumbnail caption
August 17, 2009 – 12:03am http_build_query
I can never remember the name of this function. I always google and search the php docs for things like ‘php query params’, ‘php url parameters’, ‘php query string from array’, ‘php http query params’, and I even saw “php array to post string” and for some reason this page just never comes up. Yes, this post is a selfish way for me to find this next year when I search my blog for this post!
August 10, 2009 – 10:27am symfony configuration settings, “default” versus “all”
It’s hard to keep track of the difference between the “all” parameter heading and the “default” parameter heading in your security configuration files. The way to remember it is that “default” is just that — a value for when there are no other values set, including one for “all”. More…
July 29, 2009 – 5:51pm PHP import excel (xls) files to array or csv
How have I never seen this before today?
I’ve only been working with it for a few hours but it’s amazing. It can read and write from many different formats.
Output your spreadsheet object to different file formats
- Excel 2007 (spreadsheetML)
- BIFF8 (Excel 97 and higher)
- PHPExcel Serialized Spreadsheet
- CSV (Comma Separated Values)
- HTML
Read different file formats into your spreadsheet object
- Excel 2007 (spreadsheetML)
- BIFF5 (Excel 5.0 / Excel 95), BIFF8 (Excel 97 and higher)
- PHPExcel Serialized Spreadsheet
- CSV (Comma Separated Values)
I am very excited about this. Another honorable mention is php-excel-reader which might be worth a look if you just want something a bit more simple.
July 21, 2009 – 5:06pm Propel criteria on custom columns (with addAsColumn)
This still trips me up. If you are using propel criteria objects and want to add a condition on a custom column, you have to do a bit of trickery to get it working just right. More…
July 16, 2009 – 1:38pm PHP Doctrine: Fetching related objects with hasOne relationship or one-to-zero-or-one
People new to the Doctrine ORM have a hard time understanding the magic that happens behind the scenes when you want to fetch a related object through a has-one-or-zero relationship. Looking through the doctrine-user group, it’s clear there is a lot confusion on this to newcomers, especially if you are coming over from Propel or other ORMs. It can be a pretty big conceptual change to how things are done.
More…
July 11, 2009 – 2:52am php isset and not empty
I find myself doing this a lot:
if (isset($myarray['foo']) && $myarray['foo'])) { // do something }
But I thought there had to be a better way, and one that would not throw undefined errors. A quick google search came up with a few good hits, include the PHP manual page for empty().
The manual says that when using empty(), no warnings are thrown when a variable is not set. It will return true in the following cases:
“” (an empty string)
0 (0 as an integer)
“0″ (0 as a string)
NULL
FALSE
array() (an empty array)
var $var; (a variable declared, but without a value in a class)
Keep in mind that an object with no properties is not considered empty().
Now, we can make our code a bit more beautiful:
if (!empty($myarray['foo'])) { // do something }
I’ve known about empty() for a long time, but for some reason always seemed to choose isset() over empty(), even in cases like this.
March 14, 2009 – 2:46pm Symfony Propel Enum types
Propel does not support enum column types in its schemas, since the enum type is not support across all database types. There are a few ways around this. More…
March 11, 2009 – 1:55am Symfony: How to render a partial from an action
If you ever find yourself wanting to return the contents of a partial as the entire response for an action, Symfony makes it possible. Using symfony partials with ajax, you have a lot of options of how you want to arrange your templates, but here I’ll show you what has worked best for me.
Oftentimes I find myself wanting to return the contents of a partial as the entire response for an ajax request. I do this a lot when I am already using a partial in my template, and then I want to replace that section with the results of an ajax call. We already have a partial set up to display that content, so we might as well reuse it when we have to refresh that area with new content. More…
January 23, 2009 – 4:42pm Uploading a file with Symfony 1.2
There is a post hidden within the symfony documentation that discusses how to upload a file using the new forms framework within symfony 1.2. If you are curious about the best way to handle file uploads, it’s worth reading this What’s New in Symfony 1.2 post first, and then come back here for a quick summary of how this works.
Let’s say you would like to allow users to upload PDF files to your site. You store data related to these file uploads in an “article” table in your database. This table has a column named “file” that stores the file name of the uploaded pdf.
The symfony forms framework will generate the basic (and not so basic) code to get you started. If you haven’t yet generated your form classes yet, you can do so with the command:




