Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5869

Re: Transforming object properties?

From "M. Strobel" <sorry_no_mail_here@nowhere.dee>
Newsgroups comp.lang.php
Subject Re: Transforming object properties?
Date 2012-05-09 10:05 +0200
Message-ID <a0umqjFio7U2@mid.uni-berlin.de> (permalink)
References <16764404.423.1336520688722.JavaMail.geo-discussion-forums@pblw1> <a0umljFio7U1@mid.uni-berlin.de>

Show all headers | View raw


Am 09.05.2012 10:02, schrieb M. Strobel:
> 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
>>

-cut-
> 
> $stmt = $pdo->query("select name, new_amount, old_amount from table1");
> if ($stmt) {
>    $res = $stmt->fetchAll(PDO::FETCH_CLASS);
$res is $items
> } else {
>    trigger_error('statement failed, see error messages',E_USER_ERROR);
> }
> 
> /Str.


Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


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