Ask the Expert

Perl/PHP functionality in MySQL, PostgreSQL

How different is Perl or PHP functionality in MySQL vs. PostgreSQL?

Requires Free Membership to View

This question could mean one of two things. It might be, "How do I write Perl or PHP code that uses a MySQL or PostgreSQL database?" Or, it might be, "Is it possible to write functions and procedures in MySQL and PostgreSQL using Perl or PHP?" For the former, there are a few choices. PHP offers extensions specific to MySQL and to PostgreSQL, so you might write code using mysql_query or pg_query. You can also use PDO or ODBC to connect in a more or less database agnostic manner.

For the latter, PostgreSQL offers PL/Perl and PL/php, which allow you to write procedures in Perl and PHP. PL/Perl is currently more stable than PL/php.

With the aid of some user defined functions and a thread-safe compilation, it is possible to write functions for MySQL using Perl and PHP. See and for details. It is possible that future versions of MySQL will allow a more "plug and play" approach to coding procedures in other languages.

This was first published in January 2007

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: