PDO returns erroneous columns from within pdt
Posted on
16th Feb 2014 07:03 pm by
admin
Hi All,
This is a truly weird behavior:
When using a simple pdo fetch, erroneous columns are returned!
Steps to reproduce:
------------------------------------------------------------ -----------
1.create a table with 4 columns, such as:
CREATE TABLE `t1` (
`col1` int(11) DEFAULT NULL,
`col2` varchar(20) DEFAULT NULL,
`col3` int(11) DEFAULT NULL,
`col4` int(11) DEFAULT NULL
)
2. Insert some data:
INSERT INTO t1 VALUES (1, 'test', 2, 3);
3. Try the following code:
$pdo = new PDO("mysql:host=localhost;dbname=test", 'usr', 'pwd');
$pdoStatement = $pdo->query('select * from t1');
$dbResult = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);
var_dump($dbResult);
------------------------------------------------------------ -------
This produces the results:
array(1) {
=>array(3) {
["col1"]=>
string(1) "1"
["col2"]=>
string(4) "test"
["t1"]=>
string(1) "2"
}
That is, instead of returning 4 columns named col1,col2,col3,col4,
only 3 columns are returned, col1, col2 and t1!
While t1 is the name of the table!!!!
What's going on here (This drove me crazy at first )??
By the way, when running directly from under Apache this code produces the correct results. Is this some kind of a version issue? I'm running this from the latest release of eclipse pdt: PDT 2.1-SR1, Eclipse 3.5-SR1
Is there a latter one?
Many Thanks!
Vitaliy
Many Thanks!
Vitaliy
No comments posted yet
Your Answer:
Login to answer
112
5
Other forums
Creating a function
Basically i wanna put all this code in a seperate file
Code: <?php
Multi language - seo links
Im trying to figure out the best method to have a multi language website that will function with seo
Save file by click
Hello.
I'm not understand how to save file from page. I'd like make link to file with save abil
Combining Two Queries
I have two scripts that each work fine by themselves. One is a search script with a variable that de
Working with popups and such in a class
I've recently started building my applications completely enclosed in classes. I like the fact that
rename the file
File.txt
Code: ***DOCUMENT***
..DN:
000044255
..CB:
..SN:
..PY:
2009
..E
phph within href not showing php if change ? to &
Code: [Select]<a href="<?php echo $puser; ?>?m=<?php=(($m-1)&l
Stuck with preg_replace
Hi,
I'm trying to use preg_replace to remove part of the IP address submitted using a form on
Help With editting and deleting form
Hallo !!
So look at this image :
http://img194.imageshack.us/img194/8272/snapshot5f.pn
PEAR Email Attachment w/ $gpg
I have no issues with this code if I take out the attachement section and include the info in the em