note 104647 added to book.pdo

From: Date: Tue, 28 Jun 2011 08:05:39 +0000
Subject: note 104647 added to book.pdo
Groups: php.notes 
Request: Send a blank email to php-notes+get-181012@lists.php.net to get a copy of this message
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! ---- Server IP: 195.54.192.44 Probable Submitter: 127.0.0.1 ---- Manual Page -- http://www.php.net/manual/en/book.pdo.php Edit -- https://master.php.net/note/edit/104647 Del: integrated -- https://master.php.net/note/delete/104647/integrated Del: useless -- https://master.php.net/note/delete/104647/useless Del: bad code -- https://master.php.net/note/delete/104647/bad+code Del: spam -- https://master.php.net/note/delete/104647/spam Del: non-english -- https://master.php.net/note/delete/104647/non-english Del: in docs -- https://master.php.net/note/delete/104647/in+docs Del: other reasons-- https://master.php.net/note/delete/104647 Reject -- https://master.php.net/note/reject/104647 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#181012) next »