Php – Is it possible to connect PHP to SQL Server Compact Edition

PHPsql serversql-server-ce

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


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

Best Answer

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