Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Johannes Schlüter:
JSON Aggregation functions
Sep 16, 2016 @ 16:53:25

Johannes Schlüter has written up an article covering an interesting feature of the latest MySQL server release related to its JSON column handling: JSON Aggregation functions.

[The JSON datatype, functions and generated columns] combined allow building very powerful applications without committing to a fixed data structure on every part, but I was missing one thing a lot: Aggregation.

A topic I'm thinking a lot about is finding ways to select nested data. In MySQL we typically have two ways for this. Either one sends multiple queries to retrieve different nesting levels or one builds JOINs which tend to deliver repetitive responses.

He points out that one solution is the GROUP_CONCAT function, but the results of this can be difficult to work with and larger data may override the small memory space allowed. Instead he introduces two new functions in v8 to help with this nested data selection: JSON_ARRAYAGG and JSON_OBJECTAGG. He provides a brief example of the use of these two functions together to replace the "concat" handling from before.

tagged: mysql json function v8 release aggregation tutorial

Link: http://schlueters.de/blog/archives/183-MySQL-8.0-JSON-Aggregation-functions.html

Stoyan Stefanov:
Server-side React with PHP – part 2
Sep 19, 2013 @ 14:35:38

In a a previous post Stoyan Stefanov introduced a setup where you could render React templates on the server-side with the help of PHP and the v8 parsing. In this second part of the series, he extends that system and shows how to use it to update views based on new data.

Part 1 ended with todos. The first one was to couple the server-side generated code with the client-side React, so that any updates past the initial page load will be handled by React's client JS, which is where React shines. Let's see how you can do just that.

He gives an example similar to his previous one - displaying a table - but shows how to inject some values from PHP as a JSON string into the component. This time he saves the output of that rendering into a variable and reuses it as a part of a whole site render later.

tagged: react javascript js v8 serverside render tutorial data

Link: http://www.phpied.com/server-side-react-with-php-part-2/

We Love PHP Blog:
Using V8 Javascript engine as a PHP extension
Jul 25, 2012 @ 16:50:36

From the "Web Love PHP" blog there's a new post showing how to use the V8 Javascript engine as a PHP extension in your application.

Just got to something described as: This extension embeds the V8 Javascript Engine into PHP. It is called v8js and the documentation is already available on php.net, examples and the sources are here. V8 is known to work well in browsers and webservers like node.js, but does it work inside PHP? YES!

They show how to get it installed (on Ubuntu) via a PECL install and a test script with some Javascript in a string variable that's parsed by the "executeString" function on a V8 object. There's also an example of how you can mix the functionality between the two - a simple script that uses a PHP PDO object fron inside the Javascript to perform a SQL query and set some information into the session.

tagged: v8 javascript extension integration tutorial

Link:


Trending Topics: