@ 2016-01-20T12:40:21Z <?php
$pdo = new PDO('sqlite::memory:');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec("CREATE TABLE foo(
field1 INT,
field2 INT
)");
$pdo->exec("INSERT INTO foo VALUES ('row1field1', 'row2field2'), ('row2field1', 'row2field2')");
$results = $pdo->query("SELECT * FROM foo ");
var_dump($results->fetchAll());
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.5.11 - 5.5.38 , 5.6.0 - 5.6.40 , 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 array(2) {
[0]=>
array(4) {
["field1"]=>
string(10) "row1field1"
[0]=>
string(10) "row1field1"
["field2"]=>
string(10) "row2field2"
[1]=>
string(10) "row2field2"
}
[1]=>
array(4) {
["field1"]=>
string(10) "row2field1"
[0]=>
string(10) "row2field1"
["field2"]=>
string(10) "row2field2"
[1]=>
string(10) "row2field2"
}
}
Output for 5.5.0 - 5.5.10 Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 near ",": syntax error' in /in/V1mAL:11
Stack trace:
#0 /in/V1mAL(11): PDO->exec('INSERT INTO foo...')
#1 {main}
thrown in /in/V1mAL on line 11
Process exited with code 255 . preferences:dark mode live preview
284.93 ms | 402 KiB | 330 Q