RE: [SMARTY] ADOdb with Smarty (and an array question throw in to boot!)

From: Date: Thu, 16 Dec 2004 18:05:15 +0000
Subject: RE: [SMARTY] ADOdb with Smarty (and an array question throw in to boot!)
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12052@lists.php.net to get a copy of this message
It could be the database abstraction class where the Perl DBI maybe is returning the table names in CAPS. I'm not familiar with Oracle, however, you can simply debug just one fetch set or right before you assign it into the Smarty template, type print_r($data) to visually see how the array is constructed. It should be something similar to below: Array( 0 => array('surname' => 'Mr.', 'fname' => 'Jonathan'), 1 => array('surname' => 'Ms', 'fname' => 'Kristie')); The section will loop starting with the first element in the array, and since in my example above, the print_r shows the surname is lowercase, I call it with <!---$data[set].surname---> If it was caps, then it would be <!---$data[set].SURNAME--->. To be sure, print_r($data) to see your array first. -----Original Message----- From: news [mailto:news@sea.gmane.org] On Behalf Of Robert Sent: Thursday, December 16, 2004 12:36 PM To: smarty-general@lists.php.net Subject: Re: [SMARTY] ADOdb with Smarty (and an array question throw in to boot!) "Jonathan Chum" <jchum@aismedia.com> wrote in message news:200412161657.iBGGvrbZ043707@dante.atlp.aismedia.com... > What I generally do with ADOdb is: > > $result = $adodb->query("SELECT surname, fname FROM table"); while > (!$result->EOF) { $data[] = $result->fields; } > > $smarty->assign('data', $data); > > In my Smarty template, I would loop through the result set like so: > > <!---section name="set" loop=$data---> <!---$data[set].surname---> > <!---$data[set].fname---> <BR> <!---/section---> > > Using $result->fields, the data pulled from the database is returned > as associate array which is why I can call them directly in the Smarty > template. > > BTW, try $data["SURNAME"] because without the quotes, PHP is > interepreting it as a constant. Depending on the php.ini > configuration, it will try to evaluate as a constant if you don't have the double quotes around it. > > I am using Oracle9i and in Perl the data comes back as all uppercase when I need to use it. Is it the same in PHP? In your example do I need to do "$data[set].SURNAME"? Robert -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.general (#12052) next »