PHP PDO_ODBC() or ODBC(unified)? - php

Here is the question:
I have old foxpro database that are used by my co. ERP. And I need to make a web page using PHP to display some data.
But I am not sure what I should use. In a recent project I used PHP::PDO_ODBC functions.
But one of my co-worker uses PHP::ODBC(unified) functions in one of his project.
1-What is the differences between the two?
2-Is one of them more secure?
3-Just like the MySQL functions are deprecated, is either PDO_ODBC or ODBC(Unified) deprecated??
4-Will an old FoxPRO DB or even older DB type work on both?
Thanks for any help regarding this!

I can't answer all your questions but there are a few things I learned recently. I just had to use an MS Access database in a project which is what brought me on to PDO and ODBC. I originally used ODBC, but I think the PDO is more recently updated and offers better error reporting. I couldn't get ODBC to report any query errors other than that it had failed. In the end I had to go back to using ODBC because I couldn't find the equivalent of a lot of these functions listed here in PDO (I'd already started my project in ODBC). For basic operations querying the database I found no difference between the two.
You've probably already seen this but it looks like foxPRO works fine with PDO
as seen here
(actually the bottom of this page has a link to the ODBC driver for foxPRO

Related

PDOStatement returns a string: Is this a PHP Bug?

I am considering filing a PHP bug report. My question is: Is this a PHP bug?
I am looking for a "yes"/"no" answers to help me decide if I should file the bug report.
The problem is that the PDOStatement::fetch(PDO:FETCH_NUM) for SQLite in PHP7 returns a string when it should return an array.
In 2008, PHP rejected a similar report for the MySQL Driver on bug report #44341
https://bugs.php.net/bug.php?id=44341
In report #44341, PHP programmers said that this is not a PHP bug, but a problem with the MySQL driver. MySQL fixed the problem.
Here is my argument that this is a PHP Bug.
SQLite is a public domain, standards based, "zero configuration" database that developers can embed in their product.
SQLite does not have drivers. SQLite is, by definition, an embedded database.
PDO_SQLITE is a product created by PHP which "embeds" SQLite as a driver. See the PHP manual php.net/manual/en/ref.pdo-sqlite.php
Digging deeper. It appears that the reason PDOStatement::fetch() returns a string instead of an array is that SQLite is a standards based program. The SQL standard outputs data as a string.
The MySQL driver hands PHP an array which PDO passes through to the user.
The reason that PDO fails is because the SQLite Driver delivers a string according to SQL Standards. PHP's PDO product appears to be optimized for non-standard output coming from the MySQL driver.
I consider the problems that I have to be a PHP Bug for several reasons:
1) SQLite is an embedded database. It does not have drivers. It is up to the company embedding SQLite to make SQLite work.
2) PHP advertises a product called PDO_SQLITE. This product implies that has accepted that they they have taken the responsibility of making SQLite work with their product.
(SQLite is not a client/server database. It is an embedded database making it a completely different thing.)
3) The SQLite output is based on SQL standards. The bug report #44341 tells me that PDO is dependent on the output from a proprietary third party driver.
My question for StackOverflow is: Is this a PHP bug, or am I off my rocker?
BTW, the bug I want to report is not simply that SQLite implementation of PDOStatement::fetch() returns a string.
The bug I want to report is that PHP appears to have a dependency on the MySQL Driver, MySQL is now a wholly owned division of ORACLE, and I want to avoid dependencies on ORACLE.
My question for StackOverflow is: Does my argument make sense?
If I issue the bug report, I need to have a clear argument as to why the reason PHP rejected report #44341 about MySQL does not apply to SQLite.
The following link shows the error.
http://yintercept.com/resources/new.php
I decided to file the Bug Report although I suspect an instant dismissal. A dependency on a proprietary driver is a bug in the open source world.
https://bugs.php.net/bug.php?id=71185

Preferred method of accessing MS SQL with PHP 5.3+ on Linux

What is the preferred method of accessing a Microsoft SQL Server database with PHP 5.3+ on Linux?
Given the different extension options now available I'm unsure which method is preferred based on reliability and performance. Right now I am using the mssql extension with FreeTDS, but I'd like to know if this isn't the best way.
I've heard some recommend using php-odbc/EasySoft because the mssql extension has been abandoned - yet others have said going the ODBC route isn't worth the performance hit.
The response to this stackoverflow question seems to touch on what I'm asking, however it's Windows centric.
Thank you!
I've had good results using PHP's PDO (PHP Data Objects) library for this sort of thing. There's an excellent tutorial at http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/. Just make sure you use the following template to initialize your database connection:
$dbh = new PDO("dblib:host=$host;dbname=$dbname", $user, $pass);
I use FreeTDS. It's far from satisfactory. In fact, I found your question because I live in hope that there must be a better solution and I keep looking for one. Unfortunately, FreeTDS seems to be the best option at the moment, if you're developing in a Linux environment.
If you were on Windows, you could obviously use the Microsoft SQL Server drivers for PHP which would be better, but even then there are missing features, like support for PDO lastInsertId().

What is the suggested migration route from mssql extension in php

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.

Accessing SQLite database with PHP

I am interested in using a SQLite database in my next project because it needs to be ultra-portable and a simple file that a class can connect to and use as a database seems perfect.
After Google'ing a bit I found this:
http://php.net/manual/en/book.sqlite.php
But that seems to work with an older version of SQLite and doesn't seem to be reccomended. Does anyone know what class or functions etc I should be using to use an SQLite database? I plan to write my own class for interfacing with the database, so preferably just some functions like in the link I posted but with the up-to-date version of SQLite.
Any help is appreciated, thanks.
PDO seems your best bet.
From here:
If you intend to use SQLite 3.x releases of SQLite with your development please refer to the section on PHP Data Objects, and specifically the PDO-SQLite implementation available at(references: http://us.php.net/manual/en/book.pdo.php , http://au2.php.net/manual/en/ref.pdo-sqlite.php).
PDO SQLite functions manual
Update: As #Joe mentions, there is also a standalone SQLite 3 class.
theres nothing wrong with those sqlite function, you can use them.
however there is sqlite3 http://www.php.net/manual/en/book.sqlite3.php which is object orientated.
what i personally would suggest is the adodb wrapper which can easily port to any database and is very reliable at http://de.wikipedia.org/wiki/ADOdb

How well is SQL Server implemented in PDO?

I'm getting a new project some time now and wanted to use PHP for this one, as I don't have the time to get started with MVC and absolutely hate C# for Webdev.
So I was thinking of going "back to my roots" and use PHP and PDO for that. Problem is, the Databases are all SQL Server 2003 and I don't quite know how well that is covered in PDO.
Does anybody have experience with this or should I go on getting ASP.NET-MVC into my head (Which I will do anyways, but this project needs fast deployment...)
The most common problem when using PHP and MSSQL is using an old (faulty) driver. Also, have a read of the comments on the PHP MSSQL manual page.
I don't know that PDO supports MS SQL, however I have successfully used the ADODB abstraction layer against both MS SQL 2000 and 2008 without issues. Your mileage may vary...

Categories