I don't know how Tie::DBI handles quoting, but I'll assume it does. I don't see anything immediately wrong, so I would try an insert with the normal DBI module:
use POSIX qw(strftime); my $now_string = strftime "%Y-%m-%d %H:%M:%S", localtime; use DBI; my $dbh = DBI->connect('DBI:mysql:foothills', 'root', '') or die; my $sth = $dbh->prepare("INSERT INTO users values('test', 'test', 1, 1 +, 1, 1, ?)"); $sth->execute($now_string); $dbh->disconnect();
You may want to make better fake values than I've used -- I just created a new table with a single datetime column.

If that insert works, the problem's probably somewhere in Tie::DBI. Yuck.

Update: The problem *is* in Tie::DBI, specifically within the _fields() method. It checks the allowed column names from the database, then issues the statement:

my %fields = map { lc($_)=>1 } @{$sth->{NAME}};

The lc there is the trouble.

If you add WARN => 1 to the tie statement, you'll get a warning about an unknown field named 'dateCreated' in the initialization line.

The solution is either to remove the lc() from Tie::DBI, or to use lowercase keys in the anonymous hash. Perhaps some databases don't support mixed case in field names, so Dr. Stein thought he would be safer than sorry.


In reply to Re: Tie::DBI question by chromatic
in thread Tie::DBI question by tmbg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.