If you are interested in learning what Elasticsearch has to offer you, come catch my talk at the Annual PHP Cape Town Conference.
Three days packed with interesting talks starting on the 2nd of October 2014.
If you are interested in learning what Elasticsearch has to offer you, come catch my talk at the Annual PHP Cape Town Conference.
Three days packed with interesting talks starting on the 2nd of October 2014.
Using the Elasticsearch PHP API to do an ascending sort is simple:
$params['sort'] = array('updated_at');
However I found performing a descending sort much less intuitive. Eventually I figured out it should be:
$params['sort'] = array('updated_at:desc');
Formatting of data should only occur in the final steps of output. Until that point, and as a rule, internally data should remain in a base format that can easily be converted into many others – without being converted into another more basic format first.
For example Unix timestamp for dates or a floating point number for money. Both can readily be converted into more expressive formats without writing code to first parse or disassemble the initial format.
However in a situation where the flow is very specific and unlikely to ever be used to generate a different output it is permissible, even desirable, to generate data in the format it will be finally outputted.
WARNING: Using this method will open you to Man-In-Middle_Attacks. As suggested by Filip Procházka in the comments below, you should get an up to date CA root certificate bundle and use CURLOPT_CAINFO. This article suggests a secure method for dealing with self-signed certificates.
If you’re getting stuck trying to use cURL over https in PHP, try setting both the verify peer and verify host options to false:
$url = 'https://myverysecret.domain/secrets/';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_exec($curl);