Re: newbie in datagrid

From: Date: Sat, 11 Nov 2006 13:35:09 +0000
Subject: Re: newbie in datagrid
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25771@lists.php.net to get a copy of this message
Hi Alain, A simple example to get you started: Alain Roger a écrit : > I would like to display a simple table $query = "SELECT * FROM my_table"; > - with 10 rows per page. $datagrid =& new Structures_DataGrid(10); > - if there are more records (than 10), some arrows images should be > displayed somewhere to allow user to switch among pages $pager =& Pager::factory(array('prevImg' => '<img ../>', 'nextImg' => '<img ../>')); > - to allow sorting on columns This is enabled by default > - to customize the render Simply use CSS > - to connect to postgreSQL $mdb2 =& MDB2::connect('pgsql://username:password@host/database'); Now put it all together: $options['dbc'] =& $mdb2; $datagrid->bind($query, $options); $datagrid->fill($pager); And render: $datagrid->render(); echo $pager->links; > however, i have some problem to know what will be the good DB package for > me. As Mark said, MDB2 is fine. > what can i tell, it's that i have a global variabl $db which represents the > pg_connect to postgreSQL database. > so if $db exists, therefore we are already connected to db. > > i would like to use a package like that : > package_db = $db; I don't know if you can create an MDB2 connection out of a native connection. However you can do the opposite with $mdb2->getConnection(); Regards, -- Olivier

« previous php.pear.general (#25771) next »