To further complicate matters, your database might have a TINYINT column but your queries will return its contents as strings.
On my server:
$db = new mysqli("localhost", "db_user", "****", "db_name");
/* check connection */
if ($db->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit;
}
/* If we have to retrieve large amount of data we use MYSQLI_USE_RESULT */
if ($result = $db->query("SELECT * FROM my_table", MYSQLI_STORE_RESULT)) {
$datarow = $result->fetch_array();
echo "<pre>";
var_dump($datarow);
echo "/<pre>";
}
$result->close();
The output array, $datarow returns one record from the table. Note that is_active is defined as TINYINT(1) but returns as a string in my code. In fact, all of my columns are either TINYINT or INT -- not a single one is a string. Nevertheless, the output:
array(7) {
["id"]=>
string(4) "123"
["userid"]=>
string(6) "45678"
["customer_profile_id"]=>
string(8) "01234567890"
["customer_payment_profile_id"]=>
string(8) "01234567890"
["is_active"]=>
string(1) "1"
}