Login | Register
My pages Projects Community openCollabNet

Discussions > users > Having trouble with code: propel object a non-object

propel
Discussion topic

Hide all messages in topic

All messages in topic

RE: [propel] Having trouble with code: propel object a non-object

Reply

Author "=?iso-8859-1?Q?Hallgr=EDmur_Th dot _Bj=F6rnsson?=" <hallgrimur at gmail dot com>
Full name "=?iso-8859-1?Q?Hallgr=EDmur_Th dot _Bj=F6rnsson?=" <hallgrimur at gmail dot com>
Date 2005-06-08 09:56:59 PDT
Message I changed the code

> -----Original Message-----
Ok, I found out that $cp was simply an array of zero items. Sorry for the
confusion. Just like you said :)



> From: Georg Gell [mailto:georg_1 at have2 dot com]
> Sent: 8. júní 2005 16:04
> To: users at propel dot tigris dot org
> Subject: Re: [propel] Having trouble with code: propel object a non-object
>
> After a quick glance I would say that $cp is an empty array
>
> Hallgrímur Th. Björnsson schrieb:
> > Hi.
> >
> >
> >
> > Basically, what I am trying to do is update a few rows in a database, if
> > one value (symbol) in the rows are in my array. Here is my code. It’s
> > very ugly.
> >
> >
> >
> > The if($cp ===null) is negative, so $cp isn’t null.
> >
> >
> >
> > The if(is_array) and the else are both false (how can that be!?) the
> > else is never run.
> >
> >
> >
> >
> >
> >
> >
> > foreach($finalarray as $symbol => $price)
> >
> > {
> >
> > $c = new Criteria();
> >
> >
> >
> >
> >
> >
> > $c->add(Currentp​ortfolioPeer::SYMBOL​,$symbol);
> >
> >
> >
> > $cp =
> > CurrentportfolioPeer​::doSelect($c);
> >
> > if($cp === null)
> >
> > {
> >
> > echo "null!!!";
> >
> > throw new
> > Exception("Some horrific error occurred");
> >
> > }
> >
> >
> >
> > //athugum hvort þetta sé array þ.e.
> > margir með sama symbol
> >
> > /* @var $cp CurrentPortfolio */
> >
> > if(is_array($cp))
> >
> > {
> >
> > foreach($cp as $item)
> >
> > {
> >
> > echo "Fleiri
> > en einn: symbol er : " . $symbol;
> >
> >
> > $cp->setPrice($price);
> >
> >
> >
> > }
> >
> > }
> >
> >
> >
> > else
> >
> > {
> >
> > echo "Einn:
> > symbol er : " . $symbol;
> >
> > $cp->setPrice($price);
> >
> >
> >
> > }
> >
> >
> >
> > $cp->save();
> >
> >
> >
> > }
> >
> >
> >
> > PHP says : *Fatal error*: Call to a member function save() on a
> > non-object in
> > */var/www/devel/stoc​ks/stocks/StocksModu​le/StocksDataModule.​php* on line
> > *702*
> >
> > * *
> >
> > First, how can both the if and the else not be run. That isn’t supposed
> > to be possible? Is there a bracket mistake I can’t see there?
> >
> >
> >
> > Any help is very welcome, I’m loosing my hair over this.
> >
>
> --------------------​--------------------​--------------------​---------
> To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
> For additional commands, e-mail: users-help at propel dot tigris dot org

RE: Having trouble with code: propel object a non-object

Reply

Author "=?iso-8859-1?Q?Hallgr=EDmur_Th dot _Bj=F6rnsson?=" <hallgrimur at gmail dot com>
Full name "=?iso-8859-1?Q?Hallgr=EDmur_Th dot _Bj=F6rnsson?=" <hallgrimur at gmail dot com>
Date 2005-06-08 09:24:26 PDT
Message Sent again because of errors:

> -----Original Message-----
> From: Hallgrímur Th. Björnsson [mailto:hallgrimur at gmail dot com]
> Sent: 8. júní 2005 16:14
> To: 'users at propel dot tigris dot org'
> Subject: RE: [propel] Having trouble with code: propel object a non-object
>
> You are correct in that but the strangeness remains. Take a look at my
> second message. I updated the code there.
>
> I'm beginning to think you can't nest foreach statements or something.
>
> > -----Original Message-----
> > From: Georg Gell [mailto:georg_1 at have2 dot com]
> > Sent: 8. júní 2005 16:04
> > To: users at propel dot tigris dot org
> > Subject: Re: [propel] Having trouble with code: propel object a non-
> object
> >
> > After a quick glance I would say that $cp is an empty array
> >
> > Hallgrímur Th. Björnsson schrieb:
> > > Hi.
> > >
> > >
> > >
> > > Basically, what I am trying to do is update a few rows in a database,
> if
> > > one value (symbol) in the rows are in my array. Here is my code. It’s
> > > very ugly.
> > >
> > >
> > >
> > > The if($cp ===null) is negative, so $cp isn’t null.
> > >
> > >
> > >
> > > The if(is_array) and the else are both false (how can that be!?) the
> > > else is never run.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > foreach($finalarray as $symbol => $price)
> > >
> > > {
> > >
> > > $c = new Criteria();
> > >
> > >
> > >
> > >
> > >
> > >
> > > $c->add(Currentp​ortfolioPeer::SYMBOL​,$symbol);
> > >
> > >
> > >
> > > $cp =
> > > CurrentportfolioPeer​::doSelect($c);
> > >
> > > if($cp === null)
> > >
> > > {
> > >
> > > echo "null!!!";
> > >
> > > throw new
> > > Exception("Some horrific error occurred");
> > >
> > > }
> > >
> > >
> > >
> > > //athugum hvort þetta sé array
> þ.e.
> > > margir með sama symbol
> > >
> > > /* @var $cp CurrentPortfolio */
> > >
> > > if(is_array($cp))
> > >
> > > {
> > >
> > > foreach($cp as $item)
> > >
> > > {
> > >
> > > echo
> "Fleiri
> > > en einn: symbol er : " . $symbol;
> > >
> > >
> > > $cp->setPrice($price);
> > >
> > >
> > >
> > > }
> > >
> > > }
> > >
> > >
> > >
> > > else
> > >
> > > {
> > >
> > > echo
> "Einn:
> > > symbol er : " . $symbol;
> > >
> > > $cp->setPrice($price);
> > >
> > >
> > >
> > > }
> > >
> > >
> > >
> > > $cp->save();
> > >
> > >
> > >
> > > }
> > >
> > >
> > >
> > > PHP says : *Fatal error*: Call to a member function save() on a
> > > non-object in
> > > */var/www/devel/stoc​ks/stocks/StocksModu​le/StocksDataModule.​php* on
> line
> > > *702*
> > >
> > > * *
> > >
> > > First, how can both the if and the else not be run. That isn’t
> supposed
> > > to be possible? Is there a bracket mistake I can’t see there?
> > >
> > >
> > >
> > > Any help is very welcome, I’m loosing my hair over this.
> > >
> >
> > --------------------​--------------------​--------------------​---------
> > To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
> > For additional commands, e-mail: users-help at propel dot tigris dot org

RE: [propel] Having trouble with code: propel object a non-object

Reply

Author "=?iso-8859-1?Q?Hallgr=EDmur_Th dot _Bj=F6rnsson?=" <hallgrimur at gmail dot com>
Full name "=?iso-8859-1?Q?Hallgr=EDmur_Th dot _Bj=F6rnsson?=" <hallgrimur at gmail dot com>
Date 2005-06-08 09:14:12 PDT
Message You are correct in that but the strangeness remains. Take a look at my
second message. I updated the code there.

I'm beginning to think you can't nest foreach statements or something.

> -----Original Message-----
> From: Georg Gell [mailto:georg_1 at have2 dot com]
> Sent: 8. júní 2005 16:04
> To: users at propel dot tigris dot org
> Subject: Re: [propel] Having trouble with code: propel object a non-object
>
> After a quick glance I would say that $cp is an empty array
>
> Hallgrímur Th. Björnsson schrieb:
> > Hi.
> >
> >
> >
> > Basically, what I am trying to do is update a few rows in a database, if
> > one value (symbol) in the rows are in my array. Here is my code. It’s
> > very ugly.
> >
> >
> >
> > The if($cp ===null) is negative, so $cp isn’t null.
> >
> >
> >
> > The if(is_array) and the else are both false (how can that be!?) the
> > else is never run.
> >
> >
> >
> >
> >
> >
> >
> > foreach($finalarray as $symbol => $price)
> >
> > {
> >
> > $c = new Criteria();
> >
> >
> >
> >
> >
> >
> > $c->add(Currentp​ortfolioPeer::SYMBOL​,$symbol);
> >
> >
> >
> > $cp =
> > CurrentportfolioPeer​::doSelect($c);
> >
> > if($cp === null)
> >
> > {
> >
> > echo "null!!!";
> >
> > throw new
> > Exception("Some horrific error occurred");
> >
> > }
> >
> >
> >
> > //athugum hvort þetta sé array þ.e.
> > margir með sama symbol
> >
> > /* @var $cp CurrentPortfolio */
> >
> > if(is_array($cp))
> >
> > {
> >
> > foreach($cp as $item)
> >
> > {
> >
> > echo "Fleiri
> > en einn: symbol er : " . $symbol;
> >
> >
> > $cp->setPrice($price);
> >
> >
> >
> > }
> >
> > }
> >
> >
> >
> > else
> >
> > {
> >
> > echo "Einn:
> > symbol er : " . $symbol;
> >
> > $cp->setPrice($price);
> >
> >
> >
> > }
> >
> >
> >
> > $cp->save();
> >
> >
> >
> > }
> >
> >
> >
> > PHP says : *Fatal error*: Call to a member function save() on a
> > non-object in
> > */var/www/devel/stoc​ks/stocks/StocksModu​le/StocksDataModule.​php* on line
> > *702*
> >
> > * *
> >
> > First, how can both the if and the else not be run. That isn’t supposed
> > to be possible? Is there a bracket mistake I can’t see there?
> >
> >
> >
> > Any help is very welcome, I’m loosing my hair over this.
> >
>
> --------------------​--------------------​--------------------​---------
> To unsubscribe, e-mail: users-unsubscribe@pr​opel.tigris.org
> For additional commands, e-mail: users-help at propel dot tigris dot org

Re: [propel] Having trouble with code: propel object a non-object

Reply

Author Georg Gell <georg_1 at have2 dot com>
Full name Georg Gell <georg_1 at have2 dot com>
Date 2005-06-08 09:03:40 PDT
Message After a quick glance I would say that $cp is an empty array

Hallgrímur Th. Björnsson schrieb:
> Hi.
>
>
>
> Basically, what I am trying to do is update a few rows in a database, if
> one value (symbol) in the rows are in my array. Here is my code. It’s
> very ugly.
>
>
>
> The if($cp ===null) is negative, so $cp isn’t null.
>
>
>
> The if(is_array) and the else are both false (how can that be!?) the
> else is never run.
>
>
>
>
>
>
>
> foreach($finalarray as $symbol => $price)
>
> {
>
> $c = new Criteria();
>
>
>
>
>
>
> $c->add(Currentp​ortfolioPeer::SYMBOL​,$symbol);
>
>
>
> $cp =
> CurrentportfolioPeer​::doSelect($c);
>
> if($cp === null)
>
> {
>
> echo "null!!!";
>
> throw new
> Exception("Some horrific error occurred");
>
> }
>
>
>
> //athugum hvort þetta sé array þ.e.
> margir með sama symbol
>
> /* @var $cp CurrentPortfolio */
>
> if(is_array($cp))
>
> {
>
> foreach($cp as $item)
>
> {
>
> echo "Fleiri
> en einn: symbol er : " . $symbol;
>
>
> $cp->setPrice($price);
>
>
>
> }
>
> }
>
>
>
> else
>
> {
>
> echo "Einn:
> symbol er : " . $symbol;
>
> $cp->setPrice($price);
>
>
>
> }
>
>
>
> $cp->save();
>
>
>
> }
>
>
>
> PHP says : *Fatal error*: Call to a member function save() on a
> non-object in
> */var/www/devel/stoc​ks/stocks/StocksModu​le/StocksDataModule.​php* on line
> *702*
>
> * *
>
> First, how can both the if and the else not be run. That isn’t supposed
> to be possible? Is there a bracket mistake I can’t see there?
>
>
>
> Any help is very welcome, I’m loosing my hair over this.
>

RE: Having trouble with code: propel object a non-object

Reply

Author "=?iso-8859-1?Q?Hallgr=EDmur_Th dot _Bj=F6rnsson?=" <hallgrimur at gmail dot com>
Full name "=?iso-8859-1?Q?Hallgr=EDmur_Th dot _Bj=F6rnsson?=" <hallgrimur at gmail dot com>
Date 2005-06-08 09:03:39 PDT
Message I changed my code a bit but I still find it very strange. It seems as if the
foreach statement inside the if(is_array) statement is never run. Look at
the comments after the echo statements:

 

 

                        foreach($finalarray as $symbol => $price)

                        {

                                    $c = new Criteria();

 

 

 
$c->add(Currentp​ortfolioPeer::SYMBOL​,$symbol);

                                    

                                    $cp =
CurrentportfolioPeer​::doSelect($c);

                                    if($cp === null)

                                    {

                                                echo "null!!!";

                                                throw new Exception("Some
horrific error occurred");

                                    }

 

                                    //athugum hvort þetta sé array þ.e.
margir með sama symbol

                                    /* @var $cp CurrentPortfolio */

                                    if(is_array($cp))

                                    {

                                    // echo "Is an array!"; //THIS
IS RUN!

                                                foreach($cp as $item)

                                                {

                                                            echo "More than
one symbol : " . $symbol; //THIS IS NEVER RUN!

 
$item->setPrice($price);

                                                            $item->save();

                                                }

                                                

                                                

                                                

                                    }

 

                                    else

                                    {

                                                            echo "One
symbol: " . $symbol;

                                                $cp->setPrice($price);

                                                $cp->save();

                                    

                                    }

                                    

                                    //$cp->save();

 

                        }

 

  _____

From: Hallgrímur Th. Björnsson [mailto:hallgrimur at gmail dot com]
Sent: 8. júní 2005 15:48
To: 'users at propel dot tigris dot org'
Subject: Having trouble with code: propel object a non-object

 

Hi.

 

Basically, what I am trying to do is update a few rows in a database, if one
value (symbol) in the rows are in my array. Here is my code. It’s very ugly.

 

The if($cp ===null) is negative, so $cp isn’t null.

 

The if(is_array) and the else are both false (how can that be!?) the else is
never run.

 

 

 

foreach($finalarray as $symbol => $price)

                        {

                                    $c = new Criteria();

 

 

 
$c->add(Currentp​ortfolioPeer::SYMBOL​,$symbol);

                                    

                                    $cp =
CurrentportfolioPeer​::doSelect($c);

                                    if($cp === null)

                                    {

                                                echo "null!!!";

                                                throw new Exception("Some
horrific error occurred");

                                    }

 

                                    //athugum hvort þetta sé array þ.e.
margir með sama symbol

                                    /* @var $cp CurrentPortfolio */

                                    if(is_array($cp))

                                    {

                                                foreach($cp as $item)

                                                {

                                                            echo "Fleiri en
einn: symbol er : " . $symbol;

 
$cp->setPrice($price);

                                                

                                                }

                                    }

 

                                    else

                                    {

                                                            echo "Einn:
symbol er : " . $symbol;

                                                $cp->setPrice($price);

                                    

                                    }

                                    

                                    $cp->save();

 

                        }

 

PHP says : Fatal error: Call to a member function save() on a non-object in
/var/www/devel/stock​s/stocks/StocksModul​e/StocksDataModule.p​hp on line 702

 

First, how can both the if and the else not be run. That isn’t supposed to
be possible? Is there a bracket mistake I can’t see there?

 

Any help is very welcome, I’m loosing my hair over this.
Attachments

Having trouble with code: propel object a non-object

Reply

Author "=?iso-8859-1?Q?Hallgr=EDmur_Th dot _Bj=F6rnsson?=" <hallgrimur at gmail dot com>
Full name "=?iso-8859-1?Q?Hallgr=EDmur_Th dot _Bj=F6rnsson?=" <hallgrimur at gmail dot com>
Date 2005-06-08 08:47:52 PDT
Message Hi.

 

Basically, what I am trying to do is update a few rows in a database, if one
value (symbol) in the rows are in my array. Here is my code. It’s very ugly.

 

The if($cp ===null) is negative, so $cp isn’t null.

 

The if(is_array) and the else are both false (how can that be!?) the else is
never run.

 

 

 

foreach($finalarray as $symbol => $price)

                        {

                                    $c = new Criteria();

 

 

 
$c->add(Currentp​ortfolioPeer::SYMBOL​,$symbol);

                                    

                                    $cp =
CurrentportfolioPeer​::doSelect($c);

                                    if($cp === null)

                                    {

                                                echo "null!!!";

                                                throw new Exception("Some
horrific error occurred");

                                    }

 

                                    //athugum hvort þetta sé array þ.e.
margir með sama symbol

                                    /* @var $cp CurrentPortfolio */

                                    if(is_array($cp))

                                    {

                                                foreach($cp as $item)

                                                {

                                                            echo "Fleiri en
einn: symbol er : " . $symbol;

 
$cp->setPrice($price);

                                                

                                                }

                                    }

 

                                    else

                                    {

                                                            echo "Einn:
symbol er : " . $symbol;

                                                $cp->setPrice($price);

                                    

                                    }

                                    

                                    $cp->save();

 

                        }

 

PHP says : Fatal error: Call to a member function save() on a non-object in
/var/www/devel/stock​s/stocks/StocksModul​e/StocksDataModule.p​hp on line 702

 

First, how can both the if and the else not be run. That isn’t supposed to
be possible? Is there a bracket mistake I can’t see there?

 

Any help is very welcome, I’m loosing my hair over this.
Attachments
Messages per page: