Apache serves cached files with garbled text at end

When using Apache running on a VirtualBox machine with a shared folder, small files such as JavaScript or CSS files might not get updated from the host and served with additional characters at the end. This happens because of a bug in VirtualBox when Apache is using sendfile to improve data transfer. Just turn the …

Why is your PHP output still buffered even when you turned buffering off?

If you want to stream your content with PHP, you need to have output_buffering set to off in you php.ini and/or use it together with flush(). If this still does not work check your Antivirus software. On Windows, the on-access scanners of Sophos and Avira Antivirus buffer your http output! The only solution is to …

PHP: How to sort a NodeList by element attribute

$elements = iterator_to_array($nodeList); usort($elements, function($a, $b) { return (int) $b->getAttribute(‘someAttribute’) – (int) $a->getAttribute(‘someAttribute’); });

Streaming large data (LOBs) directly into an Oracle database with PHP

The OCI library allows you to stream large data in chunks directly into a LOB instead of loading it completely into memory first. This technique is only mentioned in the article Working with LOBs in Oracle and PHP on the Oracle Technology Network, but no code example is given there, so here’s my take: $sql …

PhpStorm: Complete code versus complete current statement

Here are two useful keyboard shortcuts for PhpStorm which sound similar, but are quite different: complete code CTRL + SPACE will either finish your code if what you typed so far is unambiguous or otherwise offer a list to choose from. complete current statement CTRL + SHIFT + ENTER will add a semicolon at the …

Linux Mint 17: Install php_oci

Quick cooking recipe to install PHP oci8 on Linux Mint 17 / 18. Download the Instant Client from the Oracle Website and follow the instructions at the bottom of the download page. Download the Instant Client SDK from the same location, unpack it and move the SDK folder to the same folder where the Instant …

PHP Tip: Binding variables in a SQL WHERE IN clause

Have you ever wondered if it is possible to bind an unknown amount of variables in a SQL WHERE IN clause, e.g.: SELECT id, text FROM myTable WHERE id IN (:myId1, :myId2, myId3, …) Use a OCI collection object and wonder no more: $keyList = array(100, 250, 350); $stmt = oci_parse($cnn, “SELECT id, text FROM …

SQL tip: How to bind NULL with PHP and Oracle

Neat little trick to bind a null value without using an if clause. How often have you done something like this when a variable might be null: $sql = “SELECT * FROM someTable WHERE col1 = :firstVar”; if ($secondVar !== null) { $sql.= ” AND col2 = :secondVar”; } … oci_bind_by_name($stmt, ‘:firstVar’, $firstVar); if ($secondVar …

REST with dojo and PHP: Notes on using dgrid with a caching store

I would like to share some (personal) pitfalls I came across when creating the demo REST with dojo and PHP: Demo of a dgrid observing changes to the JsonRest store: dojo/store/Observable only works correctly when the object has an id. Unfortunately, dojo/store/Memory.add(object) does not add the id to the object when creating it (as of …

Installing Xdebug on Windows and PhpStorm

There is a catch when installing Xdebug on windows: You need to set the full path of the extension directive in the php.ini, since the default directory is only used for non-zend extensions. Also don’t forget to use quotes. ;used only for ‘normal’ extensions extension_dir = “C:Program Files (x86)PHPext” ;still necessary to use full path …