This my situation recently i am facing as a challenge,
My client website developed using Codeigniter framework on Windows platform using MSSQL database. So every file has a direct MSSQL queries to handle data.
Now they want to do a migration from MSSQL and Windows server to MySQL and Linux server. I knew, i need to do lot of work for the database migration.
But in that case (my assumption), if they would have used PDO previously as a Database layer, then i do not need to change query in each file to move MSSQL to MySQL.
Is that right?
My assumption about PDO may be stupid. But please your suggestion would be great in this scenario.
Your assumption is wrong. PDO is not a database abstraction layer, but just an interface to database. It doesn't create SQL for you, like Doctrine does. So, every query, that is using different dialect, needs to be rewritten.
I see no point in such lamentations though. Does it matter what has or would have been done? What is done that is done, you have to bear with it.
No, CodeIgniter doesn't require PDO. In fact, PDO support in CodeIgniter 2.x had an "experimental" status.
However, if your client has used custom-written SQL queries instead of CI's query builder methods, no abstraction layer would be able to help you with the migration.
PDO is a low-level abstraction that provides common function/method names for different database drivers (i.e. PDOStatement::fetch() instead of a different function name for every database); it doesn't deal with differences in SQL syntax.
Related
We are currently developing a relatively simple PHP application that makes use of an Oracle database back-end. Up until now I have been using the PHP OCI8 extension to connect to the database.
However, there is a chance in the future that we may want to use a different database (e.g. MySQL). To save myself the pain of having to rewrite the code that accesses the database, I'm considering using an abstraction layer.
PHP Data Objects (PDO) was one possibility, but only has experimental support for Oracle, so I'm eyeing up ADOdb (although I am still open to alternatives). It looks like a relatively small download and I like the idea that it can be just 'dropped-in' and included in an existing PHP application.
I have three related questions:
Is Oracle support in ADOdb good/reliable enough?
While I recognize that there will always be some performance loss when using an abstraction layer, is this likely to be excessive?
Are there any ways to improve performance when using ADOdb with Oracle (or any database in general)?
I have a little question. I am looking for a mode to connect to all types of databases using php and I don't find anything usefull. For example I am developing a platform and it will be on all kinds of databases like Mysql or PostgreSQL or others.
PHP's PDO extension has many drivers though some (Oracle for example) are marked experimental.
The database adapter class in Zend Framework does a particularly good job at abstracting connection details.
You could also try Doctrine
Use and abstract database library such as http://adodb.sourceforge.net/
Database protocols don't have a standard like HTTP does. To create something like this, you would need to create an implementation for every database. Given the number and diversity of them, this would be very difficult.
This has probably been asked before but I can't find it anywhere.
I have just found out that the mssql extension has been dumped from php (I know it was a while ago I'm a bit slow).
I have a legacy app that is using it and all the mssql_query etc functions. I'm wondering what the suggested route is?
PDO?
Microsofts Driver
Move to another DB?
I'm not entirely averse to moving to mysql since everytime I have to move boxes I have huge issues getting MSSQL to work correctly with php. Is old mysql extension still supported or do I need to move to PDO anyway?
Is there an easy way to move to PDO? Any suggestions welcome.
PDO is recommended anyway to abstract to DB connections, so if you go to MySQL I'd highly recommend using it. If you're on windows environments connecting to SQL server then the MS SQLSRV library is likely a good route to take. I have used the odbc_* functions when dealing MSSQL in the past with no problems, including calling stored procs as well as my own queries.
Another DB which didn't have OS lock in would be a good move too though. MySQL is ubiquitous, however don't rule out alternatives without doing some research first.
We have an application which uses WAMP server. Now, there is a new requirement from a customer who wants to use MS SQL Server instead of MySQL.
How easy is it to port to SQL Server from MySQL. Also it has to retain this configuration.
Apache->PHP->SQL Server on windows.
How can I connect from Apache to SQL Server. Hope PHP works well with SQL server.
Please advise.
Thanks,
Vish
You don't need to do anything special with Apache, you just need to use the correct interface in PHP. That is, the mssql stuff that Tobias linked to, or - perhaps better - PDO which can be configured to use either MySQL or MS SQL. PDO would probably be a lot easier going forward if you have to end up supporting both database engines.
In terms of differences between the MySQL and SQL Server, there are quite a lot unfortunately. Most annoying will be that the syntax for certain types of queries will be slightly different (and DDL - that is, creating tables, indexes and so on - is completely different!) Though they both support a big enough subset of standard SQL that you can usually find a way to do most everything that works in both of them. But don't expect to just connect to SQL Server and have all of your queries written for MySQL "just work" - unfortunately, they won't.
I guess in the end, the easiest thing to do is just to try it out. If it looks like it's going to be too much (for example, if you're using a lot of 'obscure' MySQL features), then you might have to rethink your options.
There are huge differences between MYSQL and MS even in basic queries.
So, all your database work should be rewritten.
The rest is not a big deal.
I'm guessing you mean MSSQL?
http://us2.php.net/mssql
mySQL... msSQL ... basically the same. You shouldn't have any problems if you don't use "fancy" queries - best would be just to try it out and see what happens.
Can any one suggest me a good framework for working with SQL Server or Oracle.
Have you looked at the SQL Server and Oracle extensions for PHP? This would be the obvious way of working with SQL Server and Oracle from PHP.
You could also try the PDO extension for PHP. It provides a consistent interface for working with different database engines. It has support for both SQL Server and Oracle.
If you are looking for a way to connect to, and modify your database with PHP, something I use and recommend is the ADOdb library ( http://adodb.sourceforge.net/ )
It allows you to abstract the database calls and use common functions for your application that are not database specific. I like this approach as I work on multiple projects that have different database requirements and it allows my code to be more portable, meaning no matter what database I am using, the code never has to change if I want to reuse it.
It also helps with code consistency across projects, and over time will help you maintain those apps more efficiently as they using a "standard" way of doing things.