All entries of my technical and business blog

Zend Framework Use Filter with Paginator

Feb 21, 2012 zend-framework

By default, when using the Zend Paginator, the result set will come back as an array. If you are using a paginator associated with a database result set, and that db has a class defined for its row, it will come back as that class. However, if this is not the case, or you are not using information from a database, you may still want a different result than just a plain array.

When Writing Unit Tests, Test Against Absolutes

Feb 14, 2012 testing

So, while chatting with one of the developers on my team, we started talking about testing an XML document creation process he had been working on. He wrote a unit test and said “see, here is my class which generates the XML, and then here I use DomDocument to add the nodes I know it will have and test against that.”

Creating a custom Zend Framework Body Script helper

Jan 31, 2012 javascript zend-framework

It drives me nuts that the best practices with javascript that is not required for the initial rendering of your application is to be placed at the bottom of the document, yet frameworks (like Zend Framework) do not support that out of the box. (I recently found out that Joomla also shares this problem.)

Split Read/Write Connections in Zend Framework Database on the Application Level

Jan 24, 2012 mysql zend-framework

I’m no sys admin, so I can’t be sure, but I’ve seen lots of issues with using things like MySQL Proxy to fully separate the write and read queries in an application. Maybe it works, I don’t know… but I do know that if I can separate the connections in my code, that saves my Admin time… it doesn’t appear to give that much of a hit to performance either! Do keep in mind that this is only working at the table level in Zend Framework. If you use their database system, this should do the trick. If you do a lot of getting the adapter yourself, this won’t help you at all!

Zend Framework Static Router URLs Not Found in Zend Navigation

Jan 17, 2012 zend-framework

For a CMS I’ve been working on, there are a number of custom routes that are added statically in a loop. These point to specific ID’s of articles on on the default module’s page viewing controller/action. Sometimes these routes need to appear in the Zend_Navigation output. As you can probably guess, the logic used for this is similar to what you might experience when using the URL view helper. But, for some reason, I could never get the URL’s to be marked as active.

How to Quickly Mask a Credit Card Number

Jan 10, 2012 php programming

So, often I have to show a masked credit card on the screen. However, I really want to go the extra mile and show the user a secure, fully masked credit card number that still reflects their original card. For example, if their credit card number is only 15 numbers long, I shouldn’t show a 16 character long string. So, I’ve developed this code snippet: