I have the following code on a PHP script:
$DB = new MeekroDB($host, $user, $pass, $dbIntra, $port, $encoding);
$DB->throw_exception_on_error = true;
$DB->error_handler = false;
$DB->throw_exception_on_nonsql_error = true;
$result = $DB->query("SELECT usr_id, usr_username, usr_blocked, usr_language, usr_nickname, entc_id FROM usuario LIMIT 1");
var_dump($result);
Resulting in the following:
array(1) {
[0]=>
array(6) {
["usr_id"]=>
string(1) "1"
["usr_username"]=>
string(12) "igor@ppp.com"
["usr_blocked"]=>
string(1) "0"
["usr_language"]=>
string(2) "ES"
["usr_nickname"]=>
string(5) "Ivan1"
["entc_id"]=>
string(1) "1"
}
}
Is there any way to have MeekroDB respect the datatypes assigned in the database model?
UPDATE
Also tried with PDO with the same result, it seems it is not MeekroDB but PHP:
$dbh = new PDO('mysql:host=...;dbname=...', $user, $pass);
$query="SELECT usr_id, usr_username, usr_blocked, usr_language, usr_nickname, entc_id FROM usuario LIMIT 1";
$data = $dbh->query($query);
$result = $data->fetchAll(PDO::FETCH_ASSOC);
var_dump($result);
UPDATE
I would expect something like this:
array(1) {
[0]=>
array(6) {
["usr_id"]=>
int(1) 1 // Notice int
["usr_username"]=>
string(12) "igor@ppp.com"
["usr_blocked"]=>
int(1) 0 // Notice int
["usr_language"]=>
string(2) "ES"
["usr_nickname"]=>
string(5) "Ivan1"
["entc_id"]=>
int(1) 1 // Notice int
}
}
The associative array should have the same datatype defined in the database.
With Meekro you cannot get typed results, as it is not using prepared statements - the only way to get the data type right off the fetch.
With PDO, it is possible only if PDO is built upon mysqlnd and emulation mode is turned off. Having there prerequisites, you can have your results already in corresponding types