php-general Digest 24 Feb 2010 16:14:58 -0000 Issue 6607

Topics (messages 302330 through 302349):

PHP or SQL to do this?
        302330 by: Rob Gould
        302332 by: Jim Lucas
        302342 by: Ian

Re: PHP / mySQL Project... Real men use 'cat'
        302331 by: Jim Lucas
        302336 by: shiplu
        302337 by: Pete Ford
        302338 by: Ashley Sheridan
        302345 by: Andrew Ballard
        302346 by: Ashley Sheridan
        302347 by: Ashley Sheridan

Re: How to get the 'return type' of a function?
        302333 by: Dasn
        302334 by: Jochem Maas

Re: $_POST vs $_REQUEST
        302335 by: Jochem Maas
        302339 by: Ashley Sheridan
        302340 by: Rene Veerman
        302341 by: Ashley Sheridan

obj in array?
        302343 by: Kim Madsen
        302344 by: Kim Madsen

Re: Fun with Streams
        302348 by: Matt Neimeyer

HipHop and other PHP compiler performance evaluation
        302349 by: Manuel Lemos

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
I'm not sure if I need to write a PHP for-loop to do this, or if it can all be 
done in one SQL statement?

Basically, I want to copy all the barcodes from one table and put them into 
another table, but only if the barcode in the first table > 0, and only if the 
wineid's match from table to table.


Steps individually are something like this:

1)  First, I get all the records from the "wine" table that have barcodes, like 
this:

        SELECT *  FROM `wine` WHERE barcode2 > 0

The fields I need are "barcode2", and "wineid"


2)  Next, I need to match all the wineid's from this "wine" table with the wine 
id's from the "usersdata" table.  Both fields in both tables are called 
"wineid".

3)  Then, if the wineid's match, I need to copy the "barcode2" value from the 
wine table and put it into the field "custombarcode" in the "usersdata" table.


I'm tempted to write a PHP script which does a while-loop through all the 
records returned from the wine table and do the matching with the usersdata 
table, but I wouldn't be surprised if there's some sort of table-join-type 
query that can do all this in one step.

--- End Message ---
--- Begin Message ---
Rob Gould wrote:
I'm not sure if I need to write a PHP for-loop to do this, or if it can all be 
done in one SQL statement?

Basically, I want to copy all the barcodes from one table and put them into 
another table, but only if the barcode in the first table > 0, and only if the 
wineid's match from table to table.


Steps individually are something like this:

1)  First, I get all the records from the "wine" table that have barcodes, like 
this:

        SELECT *  FROM `wine` WHERE barcode2 > 0

The fields I need are "barcode2", and "wineid"


2)  Next, I need to match all the wineid's from this "wine" table with the wine id's from the 
"usersdata" table.  Both fields in both tables are called "wineid".

3)  Then, if the wineid's match, I need to copy the "barcode2" value from the wine table and put it 
into the field "custombarcode" in the "usersdata" table.


I'm tempted to write a PHP script which does a while-loop through all the 
records returned from the wine table and do the matching with the usersdata 
table, but I wouldn't be surprised if there's some sort of table-join-type 
query that can do all this in one step.


Looks like you should be able to do this in the SQL. Creating a dummy DB and testing, the following seems to do the trick.

UPDATE usersdata SET
        custombarcode = (
                SELECT  barcode2
                FROM    wine
                WHERE   usersdata.wineid = wine.wineid
                AND     wine.barcode2 > 0
                )

Here is the DB schema and data that I used for the test

CREATE TABLE IF NOT EXISTS `usersdata` (
  `id` int(11) NOT NULL auto_increment,
  `wineid` int(11) NOT NULL,
  `custombarcode` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_bin AUTO_INCREMENT=7 ;

INSERT INTO `usersdata` (`id`, `wineid`, `custombarcode`) VALUES
(1, 1, 0),
(2, 2, 0),
(3, 3, 0),
(4, 4, 0),
(5, 1, 0),
(6, 1, 0);

CREATE TABLE IF NOT EXISTS `wine` (
  `wineid` int(11) NOT NULL auto_increment,
  `barcode2` int(11) NOT NULL,
  PRIMARY KEY  (`wineid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_bin AUTO_INCREMENT=4 ;

INSERT INTO `wine` (`wineid`, `barcode2`) VALUES
(1, 5),
(2, -5),
(3, 10);


--
Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

--- End Message ---
--- Begin Message ---
On 24/02/2010 05:46, Rob Gould wrote:
> I'm not sure if I need to write a PHP for-loop to do this, or if it can all 
> be done in one SQL statement?
> 
> Basically, I want to copy all the barcodes from one table and put them into 
> another table, but only if the barcode in the first table > 0, and only if 
> the wineid's match from table to table.
> 
> 
> Steps individually are something like this:
> 
> 1)  First, I get all the records from the "wine" table that have barcodes, 
> like this:
> 
>       SELECT *  FROM `wine` WHERE barcode2 > 0
> 
> The fields I need are "barcode2", and "wineid"
> 
> 
> 2)  Next, I need to match all the wineid's from this "wine" table with the 
> wine id's from the "usersdata" table.  Both fields in both tables are called 
> "wineid".
> 
> 3)  Then, if the wineid's match, I need to copy the "barcode2" value from the 
> wine table and put it into the field "custombarcode" in the "usersdata" table.
> 
> 
> I'm tempted to write a PHP script which does a while-loop through all the 
> records returned from the wine table and do the matching with the usersdata 
> table, but I wouldn't be surprised if there's some sort of table-join-type 
> query that can do all this in one step.
> 
Hi,

If your using MySQL (Other DBs may support this as well) you can insert
multiple rows like this.

INSERT INTO destination_table ( barcode2, wineID)
SELECT barcode2, wineID
FROM wine
WHERE barcode2 > 0;

(adjust to your spec)

Check out the manual page here (MySQL 5.1):

        http://dev.mysql.com/doc/refman/5.1/en/insert-select.html

You can jump to the manual for other versions from this page too.


Build up your SELECT statement first and then add the INSERT line when
you're happy its getting the right values.  If you want to be really
careful, insert into a temporary table first.


Regards

Ian
-- 




--- End Message ---
--- Begin Message ---
Paul M Foster wrote:
On Tue, Feb 23, 2010 at 11:05:14PM +0000, Ashley Sheridan wrote:

On Tue, 2010-02-23 at 15:06 -0800, Daevid Vincent wrote:
http://techrepublic.com.com/5208-12846-0.html?forumID=102&threadID=310099&messageID=3099392&tag=content;leftCol

That guy's partial to JOE. Pffft. Real men use Vim. And Emacs is for
Martians with ten fingers on each hand.

I use mg on OpenBSD.  Somewhat the same as Emacs.  Just a simplified version of 
it.


And yeah, for what it's worth, I've been running Linux since 1996.

And yeah, cats are smarter than dogs.

Flame on! ;-}

Paul



--
Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

--- End Message ---
--- Begin Message ---
Lots of confusion!

So I tried this,

$ for x in cat dog rabbit rat; do echo -n "$x "; if whatis $x >
/dev/null; then echo found; else echo not found; fi ; done;
cat found
dog not found
rabbit not found
rat not found



-- 
Shiplu Mokaddim
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

--- End Message ---
--- Begin Message ---
On 24/02/10 08:20, shiplu wrote:
Lots of confusion!

So I tried this,

$ for x in cat dog rabbit rat; do echo -n "$x "; if whatis $x>
/dev/null; then echo found; else echo not found; fi ; done;
cat found
dog not found
rabbit not found
rat not found




That's easy to fix:

sudo ln -s /bin/cat /bin/dog
sudo ln -s /bin/cat /bin/rabbit
sudo ln -s /bin/cat /bin/rat

Sorted...

--- End Message ---
--- Begin Message ---
On Wed, 2010-02-24 at 09:18 +0000, Pete Ford wrote:

> On 24/02/10 08:20, shiplu wrote:
> > Lots of confusion!
> >
> > So I tried this,
> >
> > $ for x in cat dog rabbit rat; do echo -n "$x "; if whatis $x>
> > /dev/null; then echo found; else echo not found; fi ; done;
> > cat found
> > dog not found
> > rabbit not found
> > rat not found
> >
> >
> >
> 
> That's easy to fix:
> 
> sudo ln -s /bin/cat /bin/dog
> sudo ln -s /bin/cat /bin/rabbit
> sudo ln -s /bin/cat /bin/rat
> 
> Sorted...
> 


But now they're in /bin, surely at some point you'll want to execute
these poor pets? Haven't they been through enough already?!

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Wed, Feb 24, 2010 at 5:12 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk> wrote:
> On Wed, 2010-02-24 at 09:18 +0000, Pete Ford wrote:
>> sudo ln -s /bin/cat /bin/dog
>> sudo ln -s /bin/cat /bin/rabbit
>> sudo ln -s /bin/cat /bin/rat
>>
>> Sorted...
>>
>
>
> But now they're in /bin, surely at some point you'll want to execute
> these poor pets? Haven't they been through enough already?!
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>

If you have a cat, dog, rabbit and rat together in a bin, you probably
won't have to execute them. At least not all of them.  :-P

Andrew

--- End Message ---
--- Begin Message ---
On Wed, 2010-02-24 at 09:22 -0500, Andrew Ballard wrote:

> On Wed, Feb 24, 2010 at 5:12 AM, Ashley Sheridan
> <a...@ashleysheridan.co.uk> wrote:
> > On Wed, 2010-02-24 at 09:18 +0000, Pete Ford wrote:
> >> sudo ln -s /bin/cat /bin/dog
> >> sudo ln -s /bin/cat /bin/rabbit
> >> sudo ln -s /bin/cat /bin/rat
> >>
> >> Sorted...
> >>
> >
> >
> > But now they're in /bin, surely at some point you'll want to execute
> > these poor pets? Haven't they been through enough already?!
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> 
> If you have a cat, dog, rabbit and rat together in a bin, you probably
> won't have to execute them. At least not all of them.  :-P
> 
> Andrew
> 


Reminds me of Eddie Izzards Noah's Ark sketch:

http://www.youtube.com/watch?v=CFdmG-TRxzE

The bit I'm thinking of is about 6 minutes in ;)

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Wed, 2010-02-24 at 14:24 +0000, Ashley Sheridan wrote:

> On Wed, 2010-02-24 at 09:22 -0500, Andrew Ballard wrote:
> 
> > On Wed, Feb 24, 2010 at 5:12 AM, Ashley Sheridan
> > <a...@ashleysheridan.co.uk> wrote:
> > > On Wed, 2010-02-24 at 09:18 +0000, Pete Ford wrote:
> > >> sudo ln -s /bin/cat /bin/dog
> > >> sudo ln -s /bin/cat /bin/rabbit
> > >> sudo ln -s /bin/cat /bin/rat
> > >>
> > >> Sorted...
> > >>
> > >
> > >
> > > But now they're in /bin, surely at some point you'll want to execute
> > > these poor pets? Haven't they been through enough already?!
> > >
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > >
> > 
> > If you have a cat, dog, rabbit and rat together in a bin, you probably
> > won't have to execute them. At least not all of them.  :-P
> > 
> > Andrew
> > 
> 
> 
> Reminds me of Eddie Izzards Noah's Ark sketch:
> 
> http://www.youtube.com/watch?v=CFdmG-TRxzE
> 
> The bit I'm thinking of is about 6 minutes in ;)
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 

Actually, this clip is a bit better:

http://www.youtube.com/watch?v=GrP8ey8VheU

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Tue, 23 Feb 2010 23:44:17 +0800, Nathan Rixham wrote:



As PHP is loosely typed, the only real way around this is to specify a
return type in a PHPDoc block, then parse that using reflection to get
the @return parameter.

another option is to use something like haXe which is an ECMA style
typed language that compiles to multiple targets, one of which is PHP.


Thanks Nathan for your comment. But I think the PHPDoc stuff is only for
user defined functions, right? The Reflection::getDocComment() has no idea
about the built-in functions.

--
Dasn


--- End Message ---
--- Begin Message ---
Op 2/24/10 1:16 AM, Ashley Sheridan schreef:
> On Tue, 2010-02-23 at 19:19 -0600, Kevin Kinsey wrote:
> 
>> Ashley Sheridan wrote:
>>> is_quantum() is pretty useful as well, if you want to see if it's sort
>>> of there and not at the same time. Probably turns into a cat in a box at
>>> some point too, everything quantum has cats in...
>>>
>>> Thanks,
>>> Ash
>>
>> So, should we add to the list:
>>
>> is_schrodingers_cat_alive()
>>
>> ??
>>
>> KDK
>>
> 
> 
> I think PHP would crash trying to return the boolean value from that
> one!

no. either it returns a random boolean, or the func signature is missing a
boolean $weOpenedTheBox parameter ... in which case it should be fully 
deterministic. :)

> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 
> 


--- End Message ---
--- Begin Message ---
Op 2/22/10 10:49 PM, John Black schreef:
> On 02/22/2010 11:42 PM, Michael Shadle wrote:
>> The difference here is you can at least have some control over the data
>> and expect it in a certain fashion. Also the behavior of cookies vs. get
>> vs. post are different (cookies have length and expiration limits, get
>> has length limits, post has server confgured limits)
> 
> The cookie and post/get part is all mixed up now :)
> 
> I use $_COOKIE when I want cookie information but I know that the data
> is not to be trusted and is easily fabricated.
> 
> When reading get or post I just use $_REQUEST nowadays because I don't
> have to care how the submitting form is written. This makes my form
> handling data more portable.

a. if your updating/inserting/storing data for the user you should require
POST in order to mitigate CSRF et al - not to mention using a nonce in your 
forms.

b. when you use $_REQUEST like you do you assume it's either GET or POST data, 
but
it might be COOKIE data ... which will overwrite what is sent via GET or POST 
in the
$_REQUEST array .. which creates a potential for a denial-of-service attack on 
the
users of a site:

imagine an 'id' parameter for displaying articles, then imagine a
user was tricked into loading a cookie onto his machine for your domain with the
name of 'id' and a value of 1 ... said user would only ever be able to see the
article referred to be id=1 if you wrote code that took the 'id' parameter from 
the
$_REQUEST var.

... I advocate not trusting any data *and* being explicit about the input 
vectors
on which any particular piece of data is accepted in a given context. (GET, 
POST and COOKIE
are 3 different vectors)



--- End Message ---
--- Begin Message ---
On Wed, 2010-02-24 at 07:55 +0000, Jochem Maas wrote:

> Op 2/22/10 10:49 PM, John Black schreef:
> > On 02/22/2010 11:42 PM, Michael Shadle wrote:
> >> The difference here is you can at least have some control over the data
> >> and expect it in a certain fashion. Also the behavior of cookies vs. get
> >> vs. post are different (cookies have length and expiration limits, get
> >> has length limits, post has server confgured limits)
> > 
> > The cookie and post/get part is all mixed up now :)
> > 
> > I use $_COOKIE when I want cookie information but I know that the data
> > is not to be trusted and is easily fabricated.
> > 
> > When reading get or post I just use $_REQUEST nowadays because I don't
> > have to care how the submitting form is written. This makes my form
> > handling data more portable.
> 
> a. if your updating/inserting/storing data for the user you should require
> POST in order to mitigate CSRF et al - not to mention using a nonce in your 
> forms.
> 
> b. when you use $_REQUEST like you do you assume it's either GET or POST 
> data, but
> it might be COOKIE data ... which will overwrite what is sent via GET or POST 
> in the
> $_REQUEST array .. which creates a potential for a denial-of-service attack 
> on the
> users of a site:
> 
> imagine an 'id' parameter for displaying articles, then imagine a
> user was tricked into loading a cookie onto his machine for your domain with 
> the
> name of 'id' and a value of 1 ... said user would only ever be able to see the
> article referred to be id=1 if you wrote code that took the 'id' parameter 
> from the
> $_REQUEST var.
> 
> ... I advocate not trusting any data *and* being explicit about the input 
> vectors
> on which any particular piece of data is accepted in a given context. (GET, 
> POST and COOKIE
> are 3 different vectors)
> 
> 
> 


Which becomes a moot point if you use the request_order ini setting to
specify the ordering of the overriding of variables in $_REQUEST.

I do see what you're getting at, and yes there are concerns to be had
with one global array overriding another if you don't know to look out
for such a caveat. The thing is, there are many times where $_REQUEST is
just perfect. Imagine a stylesheet picker, that remembers the visitors
choice in a cookie. You can utilise $_REQUEST to handle the whole thing
very easily, and in a way that makes sense.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
sry i gotta disagree.

a function that queries $_POST/$_GET first and then $_COOKIE seems
much wiser to me.
it consolidates all logic in the script, and making that logic obvious
by syntax, rather than relying on functionality being determined by
php.ini, which could well cause a new developer to lose heaps of time
if he/she has to work on it..

On Wed, Feb 24, 2010 at 11:18 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk> wrote:
> On Wed, 2010-02-24 at 07:55 +0000, Jochem Maas wrote:
>
>> Op 2/22/10 10:49 PM, John Black schreef:
>> > On 02/22/2010 11:42 PM, Michael Shadle wrote:
>> >> The difference here is you can at least have some control over the data
>> >> and expect it in a certain fashion. Also the behavior of cookies vs. get
>> >> vs. post are different (cookies have length and expiration limits, get
>> >> has length limits, post has server confgured limits)
>> >
>> > The cookie and post/get part is all mixed up now :)
>> >
>> > I use $_COOKIE when I want cookie information but I know that the data
>> > is not to be trusted and is easily fabricated.
>> >
>> > When reading get or post I just use $_REQUEST nowadays because I don't
>> > have to care how the submitting form is written. This makes my form
>> > handling data more portable.
>>
>> a. if your updating/inserting/storing data for the user you should require
>> POST in order to mitigate CSRF et al - not to mention using a nonce in your 
>> forms.
>>
>> b. when you use $_REQUEST like you do you assume it's either GET or POST 
>> data, but
>> it might be COOKIE data ... which will overwrite what is sent via GET or 
>> POST in the
>> $_REQUEST array .. which creates a potential for a denial-of-service attack 
>> on the
>> users of a site:
>>
>> imagine an 'id' parameter for displaying articles, then imagine a
>> user was tricked into loading a cookie onto his machine for your domain with 
>> the
>> name of 'id' and a value of 1 ... said user would only ever be able to see 
>> the
>> article referred to be id=1 if you wrote code that took the 'id' parameter 
>> from the
>> $_REQUEST var.
>>
>> ... I advocate not trusting any data *and* being explicit about the input 
>> vectors
>> on which any particular piece of data is accepted in a given context. (GET, 
>> POST and COOKIE
>> are 3 different vectors)
>>
>>
>>
>
>
> Which becomes a moot point if you use the request_order ini setting to
> specify the ordering of the overriding of variables in $_REQUEST.
>
> I do see what you're getting at, and yes there are concerns to be had
> with one global array overriding another if you don't know to look out
> for such a caveat. The thing is, there are many times where $_REQUEST is
> just perfect. Imagine a stylesheet picker, that remembers the visitors
> choice in a cookie. You can utilise $_REQUEST to handle the whole thing
> very easily, and in a way that makes sense.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

--- End Message ---
--- Begin Message ---
On Wed, 2010-02-24 at 12:34 +0100, Rene Veerman wrote:

> sry i gotta disagree.
> 
> a function that queries $_POST/$_GET first and then $_COOKIE seems
> much wiser to me.
> it consolidates all logic in the script, and making that logic obvious
> by syntax, rather than relying on functionality being determined by
> php.ini, which could well cause a new developer to lose heaps of time
> if he/she has to work on it..
> 
> On Wed, Feb 24, 2010 at 11:18 AM, Ashley Sheridan
> <a...@ashleysheridan.co.uk> wrote:
> > On Wed, 2010-02-24 at 07:55 +0000, Jochem Maas wrote:
> >
> >> Op 2/22/10 10:49 PM, John Black schreef:
> >> > On 02/22/2010 11:42 PM, Michael Shadle wrote:
> >> >> The difference here is you can at least have some control over the data
> >> >> and expect it in a certain fashion. Also the behavior of cookies vs. get
> >> >> vs. post are different (cookies have length and expiration limits, get
> >> >> has length limits, post has server confgured limits)
> >> >
> >> > The cookie and post/get part is all mixed up now :)
> >> >
> >> > I use $_COOKIE when I want cookie information but I know that the data
> >> > is not to be trusted and is easily fabricated.
> >> >
> >> > When reading get or post I just use $_REQUEST nowadays because I don't
> >> > have to care how the submitting form is written. This makes my form
> >> > handling data more portable.
> >>
> >> a. if your updating/inserting/storing data for the user you should require
> >> POST in order to mitigate CSRF et al - not to mention using a nonce in 
> >> your forms.
> >>
> >> b. when you use $_REQUEST like you do you assume it's either GET or POST 
> >> data, but
> >> it might be COOKIE data ... which will overwrite what is sent via GET or 
> >> POST in the
> >> $_REQUEST array .. which creates a potential for a denial-of-service 
> >> attack on the
> >> users of a site:
> >>
> >> imagine an 'id' parameter for displaying articles, then imagine a
> >> user was tricked into loading a cookie onto his machine for your domain 
> >> with the
> >> name of 'id' and a value of 1 ... said user would only ever be able to see 
> >> the
> >> article referred to be id=1 if you wrote code that took the 'id' parameter 
> >> from the
> >> $_REQUEST var.
> >>
> >> ... I advocate not trusting any data *and* being explicit about the input 
> >> vectors
> >> on which any particular piece of data is accepted in a given context. 
> >> (GET, POST and COOKIE
> >> are 3 different vectors)
> >>
> >>
> >>
> >
> >
> > Which becomes a moot point if you use the request_order ini setting to
> > specify the ordering of the overriding of variables in $_REQUEST.
> >
> > I do see what you're getting at, and yes there are concerns to be had
> > with one global array overriding another if you don't know to look out
> > for such a caveat. The thing is, there are many times where $_REQUEST is
> > just perfect. Imagine a stylesheet picker, that remembers the visitors
> > choice in a cookie. You can utilise $_REQUEST to handle the whole thing
> > very easily, and in a way that makes sense.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
> 


I don't think ini settings should be disregarded so easily though. There
are plenty of other ini settings that affect global variables, and can
all cause issues that can confuse the unwary developer!

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Hi folks

I'm hacking on a SOAP2 solution towards Magento and have retrieved the catalog in an array, but i'm having trouble accessing the values of the array cause there's an object in it. This is a var_dump of $my_array:

array(14) {
  [0]=>
  object(stdClass)#2 (2) {
    ["set_id"]=>
    int(44)
    ["name"]=>
    string(7) "Cameras"
  }
  [1]=>
  object(stdClass)#3 (2) {
    ["set_id"]=>
    int(38)
    ["name"]=>
    string(11) "Cell Phones"
  }

how do I access for instance set_id in $my_array[0]? I tried declaring an instance of $my_array[0] but that fails too: "Fatal error: Cannot use object of type stdClass as array "

--
Kind regards
Kim Emax - masterminds.dk

--- End Message ---
--- Begin Message ---
Kim Madsen wrote on 24/02/2010 14:02:

how do I access for instance set_id in $my_array[0]? I tried declaring an instance of $my_array[0] but that fails too: "Fatal error: Cannot use object of type stdClass as array "

$my_array[0]->set_id; did the trick


--
Kind regards
Kim Emax - masterminds.dk

--- End Message ---
--- Begin Message ---
Basically... I built the stream encapsulation to do two things for me:

1. Keep track of the row I was on.
2. Keep track of the columns by name. So if I wrote columns Foo, Bar,
Baz one time and Foo, Baz the next it would automatically keep the Baz
in column three the second time.

In other words, it makes it simple to just dump row after row of data
into it for exports and simple reports.

Matt

On Mon, Feb 22, 2010 at 4:14 AM, Rene Veerman <rene7...@gmail.com> wrote:
> just curious, why did you choose to use it from behind a stream wrapper?
>
> On Sun, Feb 21, 2010 at 11:03 PM, Matt Neimeyer <m...@neimeyer.org> wrote:
>> I created a stream wrapper around the php_writeexcel library found at
>> http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

--- End Message ---
--- Begin Message ---
FYI

http://digg.com/programming/PHP_compiler_performance

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---

Reply via email to