[plug] PostgreSQL & web page interface

Anthony J. Breeds-Taurima tony at cantech.net.au
Thu Aug 22 09:41:22 WST 2002


On Wed, 21 Aug 2002, Adrian Woodley wrote:

> I'm gonna jump in straight away before Tony or James can say anything about
> MySQL and say "YAY POSTGRES!" :) 

Hmm I feel I need to clear my name, I only use MySQL when I can't geta _real_
dbms ... postgres :) (ducks)

> Tony will probaby promote perl as the
> language of choice to interface between your database and your web-browser.
> And he's probably right, however I'm lazy :) and use PHP. Its easy to learn,

I have one killer issue with PHP that will be addressed in apache2.
If you're running a web server with multiple virtual hosts and foe sanity
reasons you invoke suexec, (that is to say each vhost has it's own uid and
gid) PHP will still run as the global httpd user.

In my mind the main advantage of perl is that you can write your business
logic once and then have serveral user interfaces
web, gtk, commandline.  If you then find a bug you only need to fix it in the
mainlibraries.  I know you _can_ do that with PHP but in my experience it is
more difficult than it needs to be.

The big advantage (which is also a liability) is the fact you can embed your
PHP code into your HTML:
consider
-----
...
<?php do DB query?>
<table>
<?php foreach ($db->res) { ?>
	<tr>
	<td>
	<?php echo $db->res->name ?>
	</td>
	<td>
	<?php echo $db->res->phnum ?>
	</td>
	</tr>
<?php } ?>
</table>
...
-----

I'm not suggesting that is good codeing but it is an advantage not available
to nitive perl.

People say that PHP is easier than perl, and to a limited degree I agree.
If you're going to learn either perl or PHP for this project then I don't
think the learning curve is any that much steper for perl.

Rasmus (PHP creator) is a nut, he claims to write cron jobs in PHP, for the
most part however I feel that perl is the best choice.

Yours Tony

   Jan 22-25 2003           Linux.Conf.AU            http://linux.conf.au/
		  The Australian Linux Technical Conference!



More information about the plug mailing list