Class::DBI::Loader. knowing table names and columns

Class::DBI::Loader. knowing table names and columns

am 29.11.2005 12:35:29 von javiermm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I just start to use Class::DBI::Loader (and Class::DBI)

I'm test their using an example from manual:

use Class::DBI::Loader;

01 my $loader = Class::DBI::Loader->new(
02 dsn => "dbi:SQLite:./cookbook.db",
03 namespace => "Data",
04 );
05 my $class = $loader->find_class('recipes'); # $class => Data::Film
06
07 my $obj = $class->retrieve_all;
08
09 while (my $recipe = $obj->next) {
10 print $recipe->title, "\n";
11 }
12
13 print join (" ",$class->columns),"\n"

In line 05, i get an object about table 'recipes', but i need to know
the name of table before to use it. How can i know what tables have mi
database (without look the table's definition ;-)?

In line 13, i get the name of columns of that table. But the order isn't
the order of definition in the table. How can i know the columns name in
same order of definition table (without look the table's definition)?

thanks


- --
Javier Maria Mora Merchan
(GPGP) Key ID: 0x794F3D83

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDjD11pRHCj3lPPYMRAjhYAKCOHc9hNISGBLImsaoGmfaGCnY75gCg qEnB
VZEUJhZlrqdHr5nyaIMbBt8=
=nJyJ
-----END PGP SIGNATURE-----

Re: Class::DBI::Loader. knowing table names and columns

am 29.11.2005 14:15:19 von javiermm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Javier M Mora (jamarier) escribió:
On Tue, 29 Nov 2005 11:35:29 +0000 (UTC), Javier M Mora (jamarier) wrote:
>
> I just start to use Class::DBI::Loader (and Class::DBI)
>
> I'm test their using an example from manual:
>
> use Class::DBI::Loader;
>
> 01 my $loader = Class::DBI::Loader->new(
> 02 dsn => "dbi:SQLite:./cookbook.db",
> 03 namespace => "Data",
> 04 );
> 05 my $class = $loader->find_class('recipes'); # $class => Data::Film
> [...]
>
> In line 05, i get an object about table 'recipes', but i need to know
> the name of table before to use it. How can i know what tables have mi
> database (without look the table's definition ;-)?
>

Ok, i found in Class::DBI::Loader::Generic:

$loader->classes to get classes name created
$loader->tables to get table names of database


- --
Javier Maria Mora Merchan
(GPGP) Key ID: 0x794F3D83

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDjFTfpRHCj3lPPYMRAimFAJ0UhS1YvCd5zQNOCWJ5ouyWCvITiQCc CrP5
NKC98AVOeg5fgkU4yZcXvIM=
=2rC7
-----END PGP SIGNATURE-----