Answer the question
In order to leave comments, you need to log in
Why does PDO SQLite return INT as STRING?
Why does PDO SQLite return INT as STRING , not as INT ? The code and result is below, please tell me where is my mistake.
the code:
<?php
$pdo = new PDO('sqlite:test.db');
$pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$pdo->query(/** @lang sqlite */
'create table if not exists test (one integer, two integer, three integer)'
);
$insert_prep = $pdo->prepare(/** @lang sqlite */
'insert into test values (:one, :two, :three)'
);
$insert_prep->bindValue(':one', 1, PDO::PARAM_INT);
$insert_prep->bindValue(':two', 2, PDO::PARAM_INT);
$insert_prep->bindValue(':three', 3, PDO::PARAM_INT);
$insert_prep->execute();
echo '<pre>';
var_dump($pdo->query(/** @lang sqlite */
'select * from test'
)->fetchAll(PDO::FETCH_NUM));
array(1) {
[0]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question