0

I've been debugging for days how to resolve a !== issue between two values. Turns out it failed because it shows up as a string instead of a int like defined in the database.

Here it shows as int:

enter image description here

But when using it, it's being defined as string:

var_dump($dbinfo['tmdb_revision']) . '<br>'; // the value from the database
var_dump($api[1]['tmdb']['revision']); // the dynamic value I compare the db value with

Results as:

string(1) "7"
int(7)

I can use

(int)$dbinfo['tmdb_revision']

But that seems weird because it's defined as int in the database and rather use that definition.

Is this a known issue and how can I resolve it?


$dbinfo is defined like so:

$titlecheck = $this->query("SELECT * FROM titles WHERE tmdb_name=:name AND tmdb_titleid=:skuid");
if($titlecheck->execute(array(":name" => $api[1]['tmdb']['name'], ":skuid" => $api[1]['tmdb']['titleid']))) {
    $dbinfo = $titlecheck->fetch(PDO::FETCH_ASSOC);

    // code starts here
J. Doe
  • 143
  • 1
  • 10
  • Where do you define `$dbinfo` ? How do you do the query to the database? – Felippe Duarte Jun 07 '18 at 18:22
  • @FelippeDuarte I've updated the question with the asked information. I feel like there's nothing wrong with it since it outputs info from the database just fine, feel free to correct me on that – J. Doe Jun 07 '18 at 18:24
  • 1
    There is nothing wrong with your query and what you are seeing is normal and correct. See the accepted answer to [this question](https://stackoverflow.com/questions/5323146/mysql-integer-field-is-returned-as-string-in-php) which reads, in part, "When you select data from a MySQL database using PHP the datatype will always be converted to a string.". – Dave Jun 07 '18 at 18:39
  • @Dave That helped. Converted all strings to a int now and all works fine. Thanks! – J. Doe Jun 07 '18 at 19:09

0 Answers0