Skip to content

Instantly share code, notes, and snippets.

@RusAlex
Created July 23, 2015 17:30
Show Gist options
  • Save RusAlex/c735596977d1ecadf2c6 to your computer and use it in GitHub Desktop.
Save RusAlex/c735596977d1ecadf2c6 to your computer and use it in GitHub Desktop.
<?php
$pdo = new PDO(
'mysql:host=localhost;dbname=yii2_basic_tests',
'',
''
);
$sth = $pdo->prepare("SELECT id, test FROM user");
$sth->execute();
$r = $sth->fetchAll(PDO::FETCH_ASSOC);
echo '<pre>'; var_dump($r); echo '</pre>'; die();
/**
* OUTPUT:
* <pre>array(2) {
* [0]=>
* array(2) {
* ["id"]=>
* string(1) "1"
* ["test"]=>
* string(1) "0"
* }
* [1]=>
* array(2) {
* ["id"]=>
* string(1) "2"
* ["test"]=>
* string(1) "1"
* }
*}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment