You are here: Class variable problem « PHP Programming Language « IT news, forums, messages
Class variable problem

Posted by tatsudoshi on 10/17/06 06:47

Hello,

I have this class http://pastebin.com/807571, where I set some variables on
__construct. Originaly I set the $total_? variables when the function
showLayout() was called. I know pastebin is having problems, so if you can't
get the code, I will upload it in plain text on my own server.
This function is called from a page object, which is called from a
controller and so on.
Doing it this way meant that all variables set during the showLayout()
function, were set to null, next time I opened the object.
Then I set it up like it is now, where I set all call variables doring
__construct and this worked fine.
But now the problem is, that the last values added to the class variables
from the showLayout() function are not added.

Is this a bug in PHP5 or am I doing something terribly wrong here?

Best regards, tatsudoshi

Added:
I have uploaded the class at http://www.criion.net/class.Kurv.php.txt

Added:
This is a snip of the code from my controller. Each page has a pagecode,
from which I select a case in a switch structur. On Kurv page, it checks to
see if the object is set, and if, gets the array from the object, otherwise
it creates the array and handles all the array related things. At the end of
the case it does this snip shown.

What it is suppose to do is first check if the useraccount can order the
item the user is trying to order.
That it check to see if the object is set, this time to either add the
array, with the new item or create a Kurv object.

I save all objects in SESSION.

if($wrong_user_account) {
$output = <<<hds
<div id='generic-content'>
<p>Denne type abonnement, kan ikke bestilles med denne konto.</p>
</div
hds;
$obj_kurv_go = new GenericOutput($output);
}
elseif(isset($this->obj_kurv)) {
$this->obj_kurv->setArray($array);
if(array_key_exists("action", $_GET) && $_GET["action"] !=
"add_to_basket"
|| array_key_exists("tilbud_id", $_GET))
$this->obj_kurv->storeLinkBack($_SERVER["HTTP_REFERER"]);

$obj_kurv_go = $this->obj_kurv;
}
else {
$link_to_basket = $this->readPage(array("mapr" => "byCode",
"sql_id" => "p_kurv_liste"))->getPageId();
$link_to_bestil = $this->readPage(array("mapr" => "byCode",
"sql_id" => "p_bestil_1"))->getPageId();
$link_to_telecare = $this->readPage(array("mapr" => "byCode",
"sql_id" => "p_telecare"))->getPageId();

$this->obj_kurv = new Kurv($array, $link_to_basket);
$this->obj_kurv->storeLinkBack($_SERVER["HTTP_REFERER"]);
$this->obj_kurv->storeLinkToBestil($link_to_bestil);
$this->obj_kurv->storeLinkToTelecare($link_to_telecare);
$obj_kurv_go = $this->obj_kurv;
}
}
$contents["gen_out"] = array($obj_kurv_go);

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация