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 #175887 is a reply to message #175884] Thu, 03 November 2011 23:20 Go to previous messageGo to previous message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma:
Senior Member
In article <j8v61o$i2r$1(at)dont-email(dot)me>,
Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:

> On 11/3/2011 6:49 PM, Tim Streater wrote:
>> 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?
>>
>
> A completely different interface, Tim. The op's code should work.

Maybe. But I know nothing of SQLiteDatabase, and the OP said this:

>> I then created the database manually from the sqlite command line and
>> tried to access it with PDO in PHP. I was able to do this, but again I
>> also want to be able to CREATE A DATABASE be it with PDO or
>> SQLiteDatabase.

So as requested, I indicated how to do it with PDO.

--
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: Mon Nov 25 21:10:59 GMT 2024

Total time taken to generate the page: 0.04725 seconds