Reply to Re: odbc: mysql vs. postgresql

Your name:

Reply:


Posted by Jerry Stuckle on 09/30/06 20:55

Jacques Lebastard wrote:
>
> I have a problem writing PHP ODBC scripts that suit both MySQL and
> PostgreSQL. So far, the following syntaxes seem to apply to each
> database (this is an 'insert' example; the same differences apply to
> 'select commands):
>
> MySQL: INSERT INTO MyTable (col1, col2) VALUES ("value1","value2")
> PGSQL: INSERT INTO "MyTable" (col1, col2) VALUES ('value1','value2')
>
> I'd like to have a single syntax for both databases. Is this possible?
> Do I need to modify either database configuration settings? Does each
> database (MySQL, PGSQL, MSSQL, Oracle, ...) use its own SQL syntax?
>
> Any advice welcome.

Both MySQL and Postgres support standardized SQL constructs, within the
restrictions of the release of code you're using (i.e. MySQL < 4.1
doesn't support subselects). So as long as you stay with this, you
could be OK.

However, this only applies to data definition language (DDL) statements
such as CREATE TABLE, and data manipulation language (DML) statements
such as SELECT and INSERT. It does not apply to database specific
things like configuration parameters. These are outside of the SQL
language, and anything supported by the database is for your convenience
only and probably not supported by other databases.

However, I question why you'd even use ODBC. If you're using PHP,
Pear::MDB is much faster and more flexible. It also runs well on every
platform, unlike ODBC.

But personally when I need both, I just encapsulate the
database-specific code in PHP classes and select which class I want.
But then all of my DB-specific code is generally in classes anyway.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация