#!/usr/bin/perl
use Mysql;
use Data::Dumper;
$host = "localhost";
$database = "ci";
$user = "root";
$pw = "wouldntyouliketoknow";
$table = "happy";
$db = Mysql->connect($host, $database, $user, $pw);
$fields = $db->listfields($table);
@hammer = $fields->name;
%hash = map { $_ => 1 } @hammer;
So you can load up a has with the field names on one side, so you can have variables like $hammer{primary_id}.
Saturday, November 6, 2010
Loading a hash with the field names from a mysql table using cpan's Mysql;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment