9 dic 2016

A way to solve "Unknown type 245 sent by the server" Google App Engine PHP

While I was programming my PHP app in Google App Engine, in the development environment I was found a issue while I want to execute a query using MySQL 5.7 specifically when I use the new feature added in to MySQL 5.7 JSON.


I reported this issue to Google at https://code.google.com/p/googleappengine/issues/detail?id=13448 but I didn't recive a response.

I did this
<?php
$sql = new mysqli('localhost','root','root','dbname');//works
$sql->query('SELECT JSON_OBJECT('key',12343) as myvalue');
?>

And then I got this error:

Warning: mysqli::query(): Unknown type 245 sent by the server. Please send a report to the developers in D:\Document...... at line ...

But, I found a way to 'fix' this problem. If the problem occurs when I use JSON, then let's no use JSON. To make this we just need CAST JSON type to CHAR(). It's something.
You just be sure choosing the appropiate lenght for the new CHAR() variable

<?php
$sql = new mysqli('localhost','user','pass','dbname');//works
$sql->query('SELECT CAST((SELECT JSON_OBJECT('key',12343)) AS CHAR(255)) as myvalue');//works too! =D
?>

This was my solution in the meantime, I hope it was useful to you.


No hay comentarios.:

Publicar un comentario

Deja tu comentario aqui...