views:

977

answers:

5

Is it possible to connect PHP to a SQL Server Compact Edition database? What would be the best driver?

A: 

The question is Why? Why not just use an Express Version?

I must say that I'm curious, but I can't say that I've used a C.E. data base for anything outside of a .Net application that had the assemblies in the application folder.

bill_the_loser
the reason is obvious, because its lightweight, doesn't run as a service on your computer and consume memory, and you open it with a single click with SQLCeEditor .
djangofan
A: 

I need it for a desktop application where SQL Server Express is too heavy.

Vincent
+2  A: 

Short Answer : No.

Long Answer : To my knowledge, unlike PostgreSQL / MySQL / MS-SQL, there is no native driver to connect PHP to SQL Server Compact Edition.

If you want to connect to it, your best bet is to use PHP ODBC connections to talk to a ODBC Driver connected to the SQL Compact server. But its pretty much a hack, and you'd be crazy to use this kind of thing for anything remotely important.

If you are worried about SQL Server Express being too heavy, use MySQL with MyISAM tables. It's pretty fast and lightweight. Emergent has a good checklist of things to configure / disable to make MySQL even faster and use less resources.


Relevant links :

MSDN Post asking the same question

Erik EJ's blog - SQL Compact with OLE DB

maxsilver
+1  A: 

You could also consider SQLite:

http://www.devshed.com/c/a/PHP/Introduction-to-Using-SQLite-with-PHP-5/

AlexCuse
+1  A: 

I've used the php-odbtp to interface PHP (with ADOdb) to a MS SQL server and it runs well, even across remote networks.

It provides a tunneling protocol from a non-odbc platform (Linux) to a service installed on the Win32 machine to buffer requests to and from an ODBC connection. Bit of a pain to setup the first time, at least 2-3 years ago when I first used it. Should also work fine for Win32<->Win32 applications.

Not familiar with SQL C.E., but I'd imagine it supports an ODBC connection of some sort, and the standard T-SQL commands.

Adam
SQL CE, it seems, does NOT support ODBC :(
Ola Eldøy