FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » sqlite and php
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: sqlite and php [message #175882 is a reply to message #175880] Thu, 03 November 2011 22:49 Go to previous messageGo to previous message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma:
Senior Member
In article
<-76e7-4b70-b81b-67d5b8b8522a(at)q13g2000vbd(dot)googlegroups(dot)com>,
Anne Achey <anneachey(at)gmail(dot)com> wrote:

> Hi,
>
> Anyone know how to create a sqlite database from PHP code? I am trying
> the code below:
>
> try
> {
> //create or open the database
> $database = new SQLiteDatabase('myDatabase.db', 0666, $error);
> }
> catch(Exception $e)
> {
> die($error);
> }

What's all this rubbish?

Try:


$connstr = "sqlite:" . $name_of_my_db;
$dbh = new PDO ($connstr);

$dbh->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);

and then to use it:

$res = $dbh->query ($sql);

if ($res===false)
{
$earray = $dbh->errorInfo ();
// Then $earray[0] has error code, more info in [1] and [2]
}

and so on. Have you not looked at the PHP website docs?

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: email sent from webpage is classed as junk
Next Topic: session cookie: client side
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 14:20:08 GMT 2024

Total time taken to generate the page: 0.05012 seconds