DMXzone Database Connector PHP Support Product Page
Not a problem
Errors in: sqlBuilder.php
Reported 14 Apr 2015 22:53:42
1
has this problem
14 Apr 2015 22:53:42 Daniel Visbal posted:
There are two errors in: sqlBuilder.php1.- Line 825: foreach ($sql->meta as $columns) {
Must be: foreach ($sql->columns as $columns) {
2.- Line 759: $this->pdo = new PDO($dsn, $user, $password, $options);
$options is undefined..
Must be: $this->pdo = new PDO($dsn, $user, $password);
Replies
Replied 15 Apr 2015 06:52:29
15 Apr 2015 06:52:29 Teodor Kuduschiev replied:
Hello Daniel,
How exactly did you end up with this conclusion? The code should be exactly as it is provided with the extension.
How exactly did you end up with this conclusion? The code should be exactly as it is provided with the extension.
Replied 15 Apr 2015 14:34:07
15 Apr 2015 14:34:07 Daniel Visbal replied:
I did activate debugging. $dmxConnectionDebug = true;
And in the output from the debug I see the following message/warnings:
{"code":2,"message":"First parameter must either be an object or the name of an existing class","file":"C:\\inetpub\\wwwroot\\ScriptLibrary\\dmxDatabaseConnector\\sqlBuilder.php","line":826,"trace":null},
I did analyze the code and in this part it it's looking for the defined columns, that are on ->colums and not in ->meta that contains the tables.
=== 2 ===
"warnings":[{"code":8,"message":"Undefined variable: options","file":"C:\\inetpub\\wwwroot\\ScriptLibrary\\dmxDatabaseConnector\\sqlBuilder.php","line":759,"trace":null}
This is related to the call to new PDO and parameter $options not defined.
And in the output from the debug I see the following message/warnings:
{"code":2,"message":"First parameter must either be an object or the name of an existing class","file":"C:\\inetpub\\wwwroot\\ScriptLibrary\\dmxDatabaseConnector\\sqlBuilder.php","line":826,"trace":null},
I did analyze the code and in this part it it's looking for the defined columns, that are on ->colums and not in ->meta that contains the tables.
=== 2 ===
"warnings":[{"code":8,"message":"Undefined variable: options","file":"C:\\inetpub\\wwwroot\\ScriptLibrary\\dmxDatabaseConnector\\sqlBuilder.php","line":759,"trace":null}
This is related to the call to new PDO and parameter $options not defined.
Replied 16 Apr 2015 18:02:47
16 Apr 2015 18:02:47 Daniel Visbal replied:
Hi:
After more analysis and review of the code:
The correct syntax for line 825 is:
foreach ($sql->meta->tables->{$sql->table} as $columns) {
Otherwise the columns are not phpFormated within the code in line 835
$data[$row][$column] = $this->convertToPHPValue($sql->adapter, $value, $type);
The difference in the output are for example:
Without correction [Integers returned as text]:
{"Cello":"12004","Canal":"1","Fecha":"2014-09-13 05:15:00"}
With correction [Integers returned a numbers]:
{"Cello":12004,"Canal":1,"Fecha":"2014-09-13T05:15:00"}
After more analysis and review of the code:
The correct syntax for line 825 is:
foreach ($sql->meta->tables->{$sql->table} as $columns) {
Otherwise the columns are not phpFormated within the code in line 835
$data[$row][$column] = $this->convertToPHPValue($sql->adapter, $value, $type);
The difference in the output are for example:
Without correction [Integers returned as text]:
{"Cello":"12004","Canal":"1","Fecha":"2014-09-13 05:15:00"}
With correction [Integers returned a numbers]:
{"Cello":12004,"Canal":1,"Fecha":"2014-09-13T05:15:00"}