473,516 Members | 3,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Small PDO problem

This is probably something that's really easy to solve, but I just can't
figure it out.

I have a "settings" table, of the following structure:

CREATE TABLE `settings` (
`id` int(10) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`value` varchar(255) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index` (`name`)
);

I am fetching everything from it with the following code:

$q = $this->h->query("SELECT name,value FROM settings");
return $q->fetchAll();

The thing is, the returned array goes in the format of $data[0]. I want
it to be like $data['test_setting'] (by the "name" column). How do I
accomplish this? I am using PDO::FETCH_ASSOC as the fetch mode.

Thanks
Oct 31 '08 #1
3 1741
On Fri, 31 Oct 2008 21:22:03 +0100, Sweetiecakes <x@x.comwrote:
This is probably something that's really easy to solve, but I just can't
figure it out.

I have a "settings" table, of the following structure:

CREATE TABLE `settings` (
`id` int(10) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`value` varchar(255) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index` (`name`)
);

I am fetching everything from it with the following code:

$q = $this->h->query("SELECT name,value FROM settings");
return $q->fetchAll();

The thing is, the returned array goes in the format of $data[0]. I want
it to be like $data['test_setting'] (by the "name" column). How do I
accomplish this? I am using PDO::FETCH_ASSOC as the fetch mode.
Euhm, RTFM?

http://nl2.php.net/PDO_statment_fetch_all

return $q->fetchAll(PDO::FETCH_ASSOC);

--
Rik
Nov 1 '08 #2
Rik Wasmus wrote:
On Fri, 31 Oct 2008 21:22:03 +0100, Sweetiecakes <x@x.comwrote:

Euhm, RTFM?

http://nl2.php.net/PDO_statment_fetch_all

return $q->fetchAll(PDO::FETCH_ASSOC);
I said I am already using PDO::FETCH_ASSOC, being set earlier with
setAttribute(); It is not working, as you can see.
Nov 1 '08 #3
Sweetiecakes wrote:
Rik Wasmus wrote:
>On Fri, 31 Oct 2008 21:22:03 +0100, Sweetiecakes <x@x.comwrote:

Euhm, RTFM?

http://nl2.php.net/PDO_statment_fetch_all

return $q->fetchAll(PDO::FETCH_ASSOC);

I said I am already using PDO::FETCH_ASSOC, being set earlier with
setAttribute(); It is not working, as you can see.
You never showed that code.

And are you positive it never got changed? Did you check it? Did you
try Rik's code? He's one of the most knowledgeable people here.

Or are you just going to argue?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 1 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3450
by: Dave Brueck | last post by:
Below is some information I collected from a *small* project in which I wrote a Python version of a Java application. I share this info only as a data point (rather than trying to say this data "proves" something) to consider the next time the "Python makes developers more productive" thread starts up again. Background ========== An...
2
1926
by: Marek Malowidzki | last post by:
Hi all, I am writing a component that exposes a C++ library as a .NET component. The approach is somewhat automatic: every library C++ class has its managed C++ counterpart that keeps a pointer to the unmanaged class instance. As usually in such a scenario, the IDisposable/Dispose()/Dispose(bool) pattern should be used. The problem is...
11
1700
by: Bo Peng | last post by:
Dear List, It is not clear what the title means. :-) Here is the details: I need to manage a big bunch of small objects, like struct{ int a; int b; }obj;
0
1473
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These icons are added to two ImageList objects which are bound to a ListView control, and everything looks great. I am saving the icons to a SQL Server...
3
2747
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These icons are added to two ImageList objects which are bound to a ListView control, and everything looks great. I am saving the icons to a SQL Server...
2
2919
by: Luc | last post by:
I saw a few posts on this newsgroup about it but nothing to help me resolve this problem: We designed a window in .NET on a platform using small fonts (120 ppp). But this window will run on servers configured with large fonts. For a reason I cant explain, not only the font changes when settings the window on large font but all the widgets...
4
2037
by: =?Utf-8?B?VzFsZDBuZTc0?= | last post by:
When one architects a new project one of the first steps in the decision is to decide on the layers. (In my opinion anyway) One architecture that I have used before is to go solid OO and create objects, which normally are very small and only deals with the stuff pertaining to that object, then break it down into Business Process, Process...
12
12128
by: elty123 | last post by:
I have a small C# program (about 400 lines of code) that is only 28kb after compiled. However when it runs (takes a whole 5 seconds) it takes up nearly 20MB of memory and I don't see why. Some of the assembly I used: using System; using System.Collections.Generic;
169
8954
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide untaking to create a toolchain for it. Way back when, there used to be something called "Small C". I wonder if the creator(s) of that would want to...
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.