new php script and sqlite
new php script and sqlite
am 08.09.2009 05:20:01 von Eric Boo
Hi,
I'm currently using a text file to store data which the php script
will read and write back to. I've a few questions:
1) I'm thinking of using sqlite, but not sure whether this will be
widely available on most hosts, as I intend for the php script to be
deployed without needing to much with much configuration. Is sqlite
included with most php setups?
2) Should I be using sqlite 2 or 3?
Thanks for your time!
Regards.
Eric
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: new php script and sqlite
am 08.09.2009 15:41:41 von Paul M Foster
On Tue, Sep 08, 2009 at 11:20:01AM +0800, Eric Boo wrote:
> Hi,
>
> I'm currently using a text file to store data which the php script
> will read and write back to. I've a few questions:
>
> 1) I'm thinking of using sqlite, but not sure whether this will be
> widely available on most hosts, as I intend for the php script to be
> deployed without needing to much with much configuration. Is sqlite
> included with most php setups?
As I understand it, sqlite support is by default built into PHP. If so,
then it should be supported anywhere.
>
> 2) Should I be using sqlite 2 or 3?
Don't use version 2. It's deprecated.
Paul
--
Paul M. Foster
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: new php script and sqlite
am 08.09.2009 17:01:27 von Eric Boo
On Tue, Sep 8, 2009 at 9:41 PM, Paul M Foster wrote:
> On Tue, Sep 08, 2009 at 11:20:01AM +0800, Eric Boo wrote:
>
>> Hi,
>>
>> I'm currently using a text file to store data which the php script
>> will read and write back to. I've a few questions:
>>
>> 1) I'm thinking of using sqlite, but not sure whether this will be
>> widely available on most hosts, as I intend for the php script to be
>> deployed without needing to much with much configuration. Is sqlite
>> included with most php setups?
>
> As I understand it, sqlite support is by default built into PHP. If so,
> then it should be supported anywhere.
Thanks for your reply.
I was under the impression that sqlite2 was supported widely by PHP,
but sqlite3 seems only to be enabled on php 5.3.0 by default.
My concern now is actually that users may find that their hosting
service providers don't provide sqlite3 out of the box.
Eric
>
>>
>> 2) Should I be using sqlite 2 or 3?
>
> Don't use version 2. It's deprecated.
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: new php script and sqlite
am 09.09.2009 21:57:18 von Ben Dunlap
> I was under the impression that sqlite2 was supported widely by PHP,
> but sqlite3 seems only to be enabled on php 5.3.0 by default.
>
> My concern now is actually that users may find that their hosting
> service providers don't provide sqlite3 out of the box.
PDO seems to support both versions:
http://us.php.net/manual/en/ref.pdo-sqlite.connection.php
So if it's practical to restrict yourself to features that are
available in both versions, you could probably do something like this:
$db_file =3D '';
$dbh =3D null;
try {
=A0 // prefer sqlite3 if available
=A0 $dbh =3D new PDO('sqlite:$db_file');
} catch (PDOException $e) {
=A0 =A0// verify that error occurred because sqlite3 is not supported
=A0 =A0try {
=A0 =A0 =A0 =A0$dbh =3D new PDO('sqlite2:$db_file');
=A0 =A0} catch (PDOException $e) {
=A0 =A0 =A0 =A0// bail out gracefully
=A0 =A0}
}
Ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: new php script and sqlite
am 09.09.2009 21:58:20 von Ben Dunlap
> =A0 $dbh =3D new PDO('sqlite:$db_file');
[8<]
> =A0 =A0 =A0 =A0$dbh =3D new PDO('sqlite2:$db_file');
But with double-quotes, not single-quotes. ;-)
Ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php