Re: Pears DB Abstraction and Smarty

From: Date: Wed, 20 Feb 2002 13:45:08 +0000
Subject: Re: Pears DB Abstraction and Smarty
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2775@lists.php.net to get a copy of this message
I suggest you to give a try to ADOdb. It's another db abstraction script. Much better and faster than Pear, i think. you can find it here: http://php.weblogs.com/ADOdb Jorge > -----Original Message----- > From: chiefmonkey [mailto:chiefmonkey@wisemonkeydesign.co.uk] > Sent: Wednesday, February 20, 2002 6:12 AM > To: smarty@lists.ispi.net > Subject: [smarty] Re: Pears DB Abstraction and Smarty > > > > I am getting a bit confused now ( easily done) > I have a php file which connects to the database using the Pear DB > abstraction layer called dbcon.php > --------------------------------- > > <?php > > //Include the extraction layer > > include("DB.php"); > > //connect to the database > $dbh=DB::connect("mysql://user:password@localhost/database); > > //execute query > $query="SELECT * FROM latestnews"; > > > $result= $dbh->query($query); > > while ($row = $result->fetchrow(DB_FETCHMODE_ASSOC)) { > $data[] = $row; > } > $dbh->disconnect(); > > ?> > which returns > > Array ( [0] => Array ( [name] => test1 [story] => test11 ) [1] > => Array ( > [name] => test2 [story] => test22 ) ) > > Then in a template I use > {include_php file="dbcon.php"} > > {foreach item=section from=$data} > {$section.name}<br> {$section.story}<br> > {/foreach} > > > Won't this work > > George > > > > At 11:39 20/02/2002 +0100, Luc Saint-Elie wrote: > >Hello, > > > >Have a look also at : > > > > >>http://www.phpinsider.com/php/code/Smarty/contribs/examples/mysql/ > > > > > >Luc > > > >At 10:36 20/02/02 +0000, Peter Bowyer wrote: > >>At 09:44 AM 2/20/02 +0000, chiefmonkey wrote: > >>> $row=$result->fetchrow(DB_FETCHMODE_ASSOC)) > >> > >>You need to use > >>while ($row = $result->...) { > >>$data[] = $row; > >>} > >>$smarty->assign('row', $data); > >> > >>and you should have more luck. Read the PEAR manual for more examples. > > > > > >--- > >You are currently subscribed to smarty as: > chiefmonkey@wisemonkeydesign.co.uk > >To unsubscribe send a blank email to $subst('Email.Unsub') > >Visit Smarty's homepage at > >http://www.phpinsider.com/php/code/Smarty/ > > > --- > You are currently subscribed to smarty as: webteam@epm.net.co > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/

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