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.
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
You could also consider SQLite:
http://www.devshed.com/c/a/PHP/Introduction-to-Using-SQLite-with-PHP-5/
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.
I wrote a php class that handles SQL compact edition files using the COM object of PHP.
This means it will only work on Windows based machines where the SQL Compact Edition runtime is installed.
You can download here (article is in German, link is at the bottom) with an example database file and script
http://www.klemmkeil.de/sql-compact-edition-sdf-mit-php-auslesen/
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.
Related
I'm trying to connect a web portal coded in PHP to a Sharepoint database. I researched and there are 2 possible options to use: MSSQL 2005 OBDC Driver and Webservices.
Which of this 2 options is the better one, and why?
https://technet.microsoft.com/en-us/library/cc793139(v=sql.90).aspx
This is an easy answer. The answer is the web services because directly querying SharePoint's databases is not allowed from a supportability standpoint (reference: https://blogs.msdn.microsoft.com/brian_farnhill/2013/12/04/directly-querying-sharepoint-databases/)
To summarize some of the core arguments is that directly talking to the database (even if it is just reads) introduces unpredictable locking of database resources which will cause problems. On top of this, the Content Database schema is not the best of my knowledge formally documented and of course subject to frequent changes. If you've ever peered inside you'll see that it is quite complicated and thus difficult to come up with generic SQL to get the data you want. The API (and therefore the web services) have done the hard work to give you a generic interface into SharePoint and to hide the complexity.
Lastly, if you are at all thinking about modifying SharePoint you are an absolute glutton for pain if you think about using direct SQL.
I am using PHP 5.3.6 on Windows and connecting to a SQL Server 2008 database.
According to the docs at MSDN there are two drivers for me to choose from.
php_sqlsrv_53_nts_vc9.dll
php_pdo_sqlsrv_53_nts_vc9.dll
The documentation on how to use each is great, but I'm not sure why I would use one over the other.
Can someone provide some insight on what the fundamental differences are (other than syntax) and why one is better than the other?
The bonus to using PDO is that if your hosting environment changes to Linux or SQL Server is not available then there is very little that you will need to change. The connection string, where you specify what sort of database (SQL Server, MySQL, SQLite etc) would be the main if not the only change needed. (apart from how you format your queries)
Next month I need to develop a script to connect to an AS400 and query some data (>1000000). I want to do this with PHP, as I am doing a lot with PHP.
My question know is, how should I connect to the As400. I know that there is ODBC, but everyone said to me ODBC is sub-optimal because it cannot handle large dataset with a great performance. Everyone recommends me JDBC.
So what do you recommend me. What would you use if you get this task... I do not plan to switch the programming language if it is not as must.
I don't know about performance on ODBC and if there are differences based on the platform you are running it against, but I believe ODBC is the only way you can connect to the i with PHP if you are using PHP on a remote server. I do know that the i can handle large amounts of data much better than most other SQL database servers.
You could also ask this question on Web400 at Midrange.com. There are several on that list that use PHP and there are even a couple of people from Zend on the list that could help you out.
The IBM i (current name of platform) has database drivers for .NET and Java.
It may be that the DB2 universal driver for your platform can connect to the system, but I do not have personal experience with that.
I am looking for a way to access and query my remote databases from my local server.
Something like PhpMyAdmin, but little more versatile.
So that I can feed it with databases I would like to see, store my queries (or better, if it has ways to access simple queries built in itself)
Can someone help me with such a PHP Script (or Class)?
Regards
Nikhil Gupta
I think it would be better to use a MySQL client instead.
I have been using sqlyog's community edition for years. It has a quick startup, and allows you to connect to multiple servers at the same time.
http://code.google.com/p/sqlyog/downloads/list
One of my favorite features is the ability to copy databases from one server to another.
( Yes, you could do this via the CLI, but having a GUI is handy. )
If it's ok to run as windows-programs, here are two suggestions:
Dbvisualizer http://www.dbvis.com/
Visual studio (even express versions) has what they call "database explorer", just install some mysql-connector that VS can handle, like odbc.
PHP has full support for mysql databases. See http://www.php.net/manual/en/ref.msql.php. Just use the address for your remote server when opening the connection.
I've got an upcoming project wherein I will need to connect our website (PHP5/Apache 1.3/OpenBSD 4.1) to our back-end system running on an iSeries with OS400 V5R3 so that I can access some tables stored there. I've done some checking around but am running into some roadblocks.
From what I've seen the DB2 extensions and DB2 software from IBM only run under Linux. I've tried compiling the extensions with all the software from IBM and even tried their precompiled ibm_db2 extension with no luck. IBM only supports Linux so I turned on the Linux emulation in the kernel but that didn't seem to help anything.
If anyone has run across getting everything to run natively under OpenBSD that would be great, but what I think I may have to do is setting up a second server running CentOS with DB2 installed (most likely via ZendCore for IBM since it seems to do all this for me) and the driver so that I can set up a small transaction server that I can post against and get a JSON representation of the DB2 data that I need.
Does the second option seem overkill or does anyone else have any better ideas?
Have you looked at connecting to the server using unixODBC? If I remember correctly it has support for IBM DB2 and compiles on OpenBSD. Check out http://www.php.net/odbc for more information regarding the PHP side.
If you can't get that to work, the option to setup a web service on a Linux server may be all you can do.
Rather than setup a 2nd box, why don't you look into the PHP Connector for iSeries? My mainframe guys said it was very easy to setup on our iSeries here.
We wrote a simple server in PHP that loads data models from DB2 data, serializes them, and returns them to the caller. This approach means that only another PHP app can consume the service but it's just so much quicker on both ends to just serialize the object and send it down the pipe.
Here is a PDF from IBM on the subject: http://i-seriesusergroup.org/wp-content/uploads/2006/09/PHP%20for%20i5OS%20NESDND.pdf
To second #John Downey, I've gotten connectivity to work with PHP on an AS/400 with unixODBC.
Check your phpinfo() to see if unixODBC is available in it. I didn't have to compile it in on SLES 10.
Looks like a web service is going to be the answer for me. On a production box I'd rather not have to go through compiling and maintaining my own special installation of PHP since ODBC support needs to be compiled in, according to the PHP documentation.
A web service is almost certainly the way to go. I'm sure you've already thought of this, but since you're doing PHP on both sides, you can shortcut things a little bit by using serialize() to build your response data instead of building a proper XML document. It's less flexible over the long run, but it will probably get you up and running more quickly.
Indeed, a webservice seems like a great way to solve the problem. One way to avoid having a completely separate OS for it would be to write the webservice in Java on top of the AS400 tools for Java (which are quite nice, btw). That should at least let you run your service layer on the OpenBSD box as well.
You can connect directly using a standard ODBC driver as well. The IBM version usually gives you more features like being able to call programs and things like that. If you only need SQL and stored procedures, ODBC should work.
Why not use PDO from PHP? I have to guess here since I could not find a public list of all ports available for OpenBSD, but since there is a port for FreeBSD, NetBSD etc. maybe you get lucky as well.
(I guess that even though OpenBSD links to FreeBSD's porter's handbook, Freshports is not applicable for your system?)
If PDO is not available and since I am hoping you use ports and according to the following link there is php5-ODBC available:
http://www.openbsd.org/pkg-stable40.html
So assuming you manage your system through ports, there are your pointers.
Hope that helps!