Re: newbie in datagrid
| From: | Mark Wiesemann | Date: | Fri, 10 Nov 2006 20:47:16 +0000 |
| Subject: | Re: newbie in datagrid | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25761@lists.php.net to get a copy of this message | ||
Alain Roger wrote:
> I'm new to the world of PEAR.
> I've seem an example of what could be done with PEAR packages and it was
> great.
>
> Now i would like to use it on my website by i'm quite confused.
> I would like to display a simple table
> - with 10 rows per page.
> - if there are more records (than 10), some arrows images should be
> displayed somewhere to allow user to switch among pages
> - to allow sorting on columns
> - to customize the render
> - to connect to postgreSQL
>
> to do that i was thinking to use :
> - structures/datagrid
>
> however, i have some problem to know what will be the good DB package for
> me.
>
> 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;
> package_query = $query;
>
> and get the output to a render like HTML table with paging and customization
> of colors,...
>
> So, which DB object/package do you advise me and how to use it ?
PEAR has three packages for database abstraction: DB, MDB and MDB2. DB
is since a few months deprecated in favor of MDB2, which is the
successor of the MDB package.
=> MDB2 is the best package to use (together with MDB2_Driver_pgsql)
You can directly use MDB2 and SQL queries with Structures_DataGrid (SDG)
via the MDB2 DataSource driver. More advanced possibilites are offered
by DB_DataObject and DB_Table (both also support MDB2 as backends, not
only DB as the names might indicate).
> moreover, which render could be the most interesting for me ?
You wrote that you want to output an HTML table. For me it is pretty
obvious which would be the right renderer ... (=> HTML_Table renderer)
Of course, you also need to install the Pager renderer to make the
paging links work.
I haven't answered on all points of your mail, as there were no much
question marks, and I assumed that you already found out that SDG offers
the things you wrote about.
Regards,
Mark