Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: DBI::SQLite and apache

by CountZero (Bishop)
on Jun 12, 2009 at 18:56 UTC ( #771062=note: print w/replies, xml ) Need Help??


in reply to DBI::SQLite and apache [SOLVED]

How do you know that the connect, the prepare and the execute "work fine"? You do not test the return value of these functions.

Add some or die ... or or warn ... code to these functions and see what that does.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: DBI::SQLite and apache
by afoken (Chancellor) on Jun 12, 2009 at 20:18 UTC

    Even better: Let DBI do that for you: connect with RaiseError => 1 and every failing DBI method will die automatically. If you expect that a function may die, wrap in in an eval { BLOCK }. This is the usual way to handle transactions: Code that may fail and the final commit are wrapped in eval, followed by a rollback when $@ is true.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      Much appreciated!
Re^2: DBI::SQLite and apache
by halfcountplus (Hermit) on Jun 12, 2009 at 19:09 UTC
    How do you know that the connect, the prepare and the execute "work fine"? You do not test the return value of these functions.

    No, but there are already "subjects" in the database and these are read and displayed correctly. Perhaps I should have explained this further...in any case, it is *not* because $db is a bad handle. I will add the warns tho, you are right, they should be there from the start.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://771062]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2023-05-31 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?