note 104647 rejected from book.pdo by danbrown
| From: | danbrown@php.net | Date: | Tue, 28 Jun 2011 19:22:27 +0000 |
| Subject: | note 104647 rejected from book.pdo by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-181020@lists.php.net to get a copy of this message | ||
Note Submitter: fexuse at gmail dot com
----
I am in despair!
So, I have
mySQL table:
CREATE TABLE categories(
id INT(11),
parent_id INT(11),
name VARCHAR(155),
note VARCHAR(155)
INSERT INTO categories (ID, parent_id, name, note) VALUES (1, 0, 'test', 'test
note');
and simple php code:
$dsn = 'mysql:dbname=trader;host=localhost';
$pdo = new PDO($dsn, 'root', '',
array(PDO::ATTR_PERSISTENT=>DB_PERSISTENCY));
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sel = 'SELECT * FROM categories;';
$array = $pdo->query($sel)->fetchAll(PDO::FETCH_ASSOC);
print_r($array);
Output Result:
Array
(
[id] => 1
[parent_id] => 0
[categories] => 'test'
[trader] => 'testnote'
)
!!! look at the array of field names!!!
Why this?
Field 3 = "categories"??? (table name)
Field 4 = "trader"??? (db name)
Why this error may occur?
Thanks!