Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #5868
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.erje.net!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
| Newsgroups | comp.lang.php |
| Subject | Re: Transforming object properties? |
| Date | Wed, 09 May 2012 10:02:59 +0200 |
| Lines | 40 |
| Message-ID | <a0umljFio7U1@mid.uni-berlin.de> (permalink) |
| References | <16764404.423.1336520688722.JavaMail.geo-discussion-forums@pblw1> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de aJJStQZ4tQvbxV/Ad+EpbQc0rwFjx57ApDQLqszUHRC4K/xu9UJFp3gLQQfD3ZmWo= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0 |
| In-Reply-To | <16764404.423.1336520688722.JavaMail.geo-discussion-forums@pblw1> |
| Xref | csiph.com comp.lang.php:5868 |
Show key headers only | View raw
Am 09.05.2012 01:44, schrieb Mike:
> I need an array of objects that looks like this:
>
> $items[$i]->name
> ->new_amount
> ->old_amount
>
> The data would look like this:
>
> name new_amount old_amount
> John 500.00 200.00
> Sue 15.00 <NULL>
> Frank 254.00 <NULL>
> Max <NULL> 28.00The data would look like this:
>
> But the results of my sql query comes back as:
>
> $items[$i]->name
> ->type
> ->amount
>
> name type amount
> ----------------------------------
> John new_amount 500.00
> John old_amount 200.00
> Sue new_amount 15.00
> Frank new_amount 254.00
> Max old_amount 28.00
>
> Is there a reasonable way to accomplish this?
$stmt = $pdo->query("select name, new_amount, old_amount from table1");
if ($stmt) {
$res = $stmt->fetchAll(PDO::FETCH_CLASS);
} else {
trigger_error('statement failed, see error messages',E_USER_ERROR);
}
/Str.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Transforming object properties? Mike <mpearl1@gmail.com> - 2012-05-08 16:44 -0700
Re: Transforming object properties? Jeff North <jnorthau@yahoo.com.au> - 2012-05-09 11:01 +1000
Re: Transforming object properties? Mike <mpearl1@gmail.com> - 2012-05-09 14:57 -0700
Re: Transforming object properties? Captain Paralytic <paul_lautman@yahoo.com> - 2012-05-10 03:24 -0700
Re: Transforming object properties? Jeff North <jnorthau@yahoo.com.au> - 2012-05-15 10:28 +1000
Re: Transforming object properties? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-15 20:09 +0200
Re: Transforming object properties? "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-05-09 10:02 +0200
Re: Transforming object properties? "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-05-09 10:05 +0200
csiph-web