Finally, a chmod Reference I Will Remember

I haven’t posted on here in over 2 months, mostly because I have been busy a) fathering 2 girls, and b) working my butt off.  Maybe I just haven’t learned many new tricks lately.

However, I found this page yesterday, showing the binary translations of chmod hex commands:

http://catcode.com/teachmod/numeric.html

I can never remember if 5 is “read execute” or “read write”.   Well…now, I have a handy reference to remember.

And now, so do you.

Flexible Data Display with PDO and HTML_Table_Matrix

Have you ever wanted to set up an application that displays tabular data, and wanted to use the same view for each query?  While PHP is excellent for writing small-footprint queries, its ability to be embedded in HTML leaves the creativity to the programmer to figure out a consistent display solution for tabular data.

We need two things – first, we need a way to dynamically retrieve table information, query information, and query results.  Second, we need a way to dynamically build the display based on the information we have.  Using the metadata methods of PDO, along with PEAR::HTML_Table_Matrix, we can do just this. Continue reading ‘Flexible Data Display with PDO and HTML_Table_Matrix’

Writing a Cross-Domain Proxy in PHP

Today I encountered a problem that many developers will likely face while building a web application with Ajax, so I wanted to share my experience with it.

The Problem:

You create a web site with the goal of consuming content from the web.  This may be in the form of a geocoding service, or perhaps a lightbox service for browsing images.  You need to load an external resource though Ajax.  The XMLHttpRequest object cannot make a connection, and you receive a javascript error, or a blank page. Continue reading ‘Writing a Cross-Domain Proxy in PHP’

New Page – Useful Scripts

I have created a new page for featuring little snippets of code that I think others may find useful. Its name, quite uncreative, is “Useful Scripts”.

http://codemill.studio-connect.com/useful-scripts/

The first function posted is for getting the difference between two dates. This function takes two dates that are convertible to Unix timestamps using strtotime(), and will return an array of the number of years/months/days between the two dates. The number of days between a leap and non-leap year is not correct yet, that is on my to-do list.

PHP 5.3 introduces the new DateInterval class which will help parse dates and provide native dateDiff functionality to PHP. Until we are all on 5.3, hopefully this will help someone else.

Until next time.

PHP and Javascript Combine with PHP.JS

I wanted to write a quick post about a library one of my co-workers stumbled upon this week.  It is called php.js and is a compilation of php functions ported to javascript.  That sounds pretty convenient!

Continue reading ‘PHP and Javascript Combine with PHP.JS’

Working on a Propel Form Builder…

Tonight I started working on a set of classes that will build forms for Propel objects.  While Propel already has implementations of PatForms and HTML_QuickForm, they are both not up-to-date in svn.  They both also require Creole for gathering metadata, and I am not at all interested in integrating another library into this project – especially one labeled “dead” on its own site.

Continue reading ‘Working on a Propel Form Builder…’

Quick PHP Debugging with FirePHP

Recently when browsing past issues of php|architect magazine, I came across mention of a Firefox add-on called FirePHP. For those who have not heard of it, FirePHP is both a Firefox add-on and a PHP library used to send messages to the Firebug console.
Continue reading ‘Quick PHP Debugging with FirePHP’