Looking at the code in the previous entry wasn’t exactly a pleasant aesthetic experience (sorry for that, bit of a botched job) so for my new project, an implementation of the NIST RBAC model in PHP, I decided to code a nice generic PHP query engine. The Query Engine takes a number of arguments like the SQL query, the arguments for the query (to be passed into prepared statements), the types of the arguments and whether the query is part of an overall transaction. The nice thing is that the QueryEngine function returns the results as an associative array using the database column names as the key value.
Transactions, prepared statements and PHP mysqli
Posted: October 2, 2009 at 9:39 pm
While working with my good friend Arnold Consten on his new PHP application we came across some nice learning points for dealing with mysqli transactions and prepared statements. It turns out that the order of events is very specific for transactions and prepared statements to work correctly together:
Templates, template engines and PHP
Posted: October 2, 2009 at 6:48 pm
In the process of developing Lilliput CMS I had to think about how to do templating with PHP. There’s a lot of material available regarding PHP and templating and most of it is really weird. Having had a look at the Top 25 PHP template engines I can’t for the life of me understand why I would want to use something like Smarty, Savant or phptal. Obviously a lot of love and attention has been poured into these solutions but I can’t escape the feeling that these template engines are recreating PHP and its innate templating function. This feeling was confirmed when reading the “Templates and template engines” article on the php patterns website.
Lies, damned lies and caching
Posted: October 2, 2009 at 6:47 pm
One of the most excellent aspects of HTTP and the underpinning REST architecture is the aspect of idempotence and non-idempotence. Idempotence roughly means that some operation yields the same result whether it is done only once or several times. This behaviour forms the basis of caching because if the result is the same you can work with a copy of the result for all subsequent requests. This excellent property of the web also has some downsides as the Law of Preservation of Complexity demands that for any goodness in technology there always is a trade off in increased complexity somewhere else. In the case of caching it is determining when to cache and when not to cache.
How to use PHP XPath queries with XHTML
Posted: October 2, 2009 at 6:46 pm
My work for the Lilliput CMS has lead to some interesting new findings about PHP 5′s new DOM functions, particularly the XPath part of it. Whilst working on the templating structure for Lilliput I couldn’t get the DOM XPath queries to work on the file at hand, a normal XHTML 1.0 Strict document. With an external tool called XPath Explorer (XPE) every query evaluated correctly but as soon as I tried the same XPath expression in PHP it failed. After searching long and hard I came across a code snippet that contained the solution namely to explicitly declare the xhtml namespace for the DOM document you’re working on:
Building the previous blog
Posted: October 2, 2009 at 6:45 pm
This blog uses used a novel approach (I think) in that it is was entirely Atom 1.0 based. There is was no underlying (X)HTML, everything is was Atom (with a hint of XSL). I came to this approach after I figured out that it is silly to serve the same content in multiple formats when one format suffices. Modern browser are perfectly capable of executing XML/XSL that allow for the transformation of the Atom 1.0 feed into XHTML. There’s some nice stuff going, let’s dig into the details (hey I’m a technologist at heart so why not busy myself with the stuff I love).