[TYPO3-commerce] extensions of the extension using $this->piVars

Franz Koch typo.removeformessage at fx-graefix.de
Fri Oct 26 11:34:30 CEST 2007


Hi,

> i am busy extending commerce a little - am wanting to show the gn_id 
> which is stored in the fe_users table:
> 
>     function additionalMarker($markerArray,&$subpartArray,&$this) {

ouch, very bad. don't ever use '$this' as name for a variable - better 
use something like '$parent'.

>         echo $this->piVars["order_id"];
>         $res = 
> $GLOBALS['TYPO3_DB']->exec_SELECTquery('fe_users.tx_gn_gn_id', 
> 'fe_users, tx_commerce_orders', 'fe_users.uid = 
> tx_commerce_orders.cust_fe_user AND tx_commerce_orders.order_id = ' . 
> $this->piVars["order_id"]);
>         $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
>         $markerArray['###REP_ID###'] = $row['tx_gn_gn_id'];
>         return $markerArray;
>     }
> 
> the marker is displays nicely on my local webserver. as soon as i put 
> the extension online - to the live server the line:  echo 
> $this->piVars["order_id"]; does not return anything and the of course i 
> get a sql error.

I could imagine, that the error is related by redeclaring $this as 
mentioned above. Use something else, as $this is a preserved namespace 
of your class.

And to see why there is a DB error, set the following line somewhere 
before your SQL statements:

$GLOBALS['TYPO3_DB']->debugOutput = 1;

> have you got any idea why $this->piVars["order_id"] has got a value on 
> the one system and is empty on the remote? all else is working fine.

yes - as mentioned above $this might cause problems. I guess your local 
webserver runs with php 4.x while your live server has php 5.x. The 
later normally throws errors when you try to redeclare $this.

--
Greetings,
Franz


More information about the TYPO3-project-commerce mailing list