Kategorie: PHP
-
Lazy loading in PHP
In more projects than I care to think about, I’ve seen a pattern that I dislike the more I see it. It appears quite innocent, but it brings about cost with no discernible benefit. Including all of the application’s source code on each and every call being made to a page. It may be that…
-
Installing apache, fastcgi & php-fpm on dragonflybsd
We’re currently in the process of transitioning our web servers from NetBSD to DragonflyBSD; along with that, we’re also switching our PHP platform to php-fpm. There are a few lessons we learned in the process. First: At least on DragonflyBSD 2.10, apache2 does not at all perform well as apache-mpm-worker. Switching to apache-mpm-prefork changed our…
-
The library now is able to …
I’m currently writing a library of PHP stuff for our internal use. I’ve been able to make it do a few fun tricks. To express a query with a subquery, I can now do this: $sube = new Expression('subtable'); $sube->setResultField('id'); $sube->beginGroup('and'); $sube->addTerm('field1','=',$valueA); $sube->addTerm('field2',' =','expr:now()'); $sube->endGroup; $e = new Expression('table'); $e->addTerm('field2','not in',$sube); $XQDB->getObjects($e); I like that!
-
Requiring code in PHP
While writing the code to handle a small form in PHP, I just realized that I have a very bad habit – and many just do the same. When I write a new file, I place all the includes at the very top, before anything else happens. But in my current script, there are many code…