Re: PHP sucks!! - was: persistent db connections in PHP

From: PFC <lists(at)peufeu(dot)com>
To: rod(at)iol(dot)ie
Cc: lawpoop(at)gmail(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: PHP sucks!! - was: persistent db connections in PHP
Date: 2007-06-16 16:24:23
Message-ID: op.tt0vuxiscigqcu@apollo13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> I've seen similar negative comments before on this list about PHP, and
> I'm curious to know what informs them.

Maybe the fact that, when I coded a database object/form library, it took
me LONGER to ensure that empty strings / NULLs / zero valued floats and
integers / etc were handled correctly than it took me to code the entire
thing ?

> I use PHP quite a bit, and though I wouldn't claim to be any sort of an
> expert, I like it a lot: IMHO it's powerful, fast and easy to use. Mind
> you, I came to PHP from an ASP/VBscript background, so anything would
> have been an improvement.

LOL. Yeah.

> Having said that, the main gripes I would have with PHP are (i)
> variables aren't strongly typed, which can bite you unless you're
> careful, and (ii) you don't have to declare variables before using them,
> which can also cause trouble - in VBScript you have "option expicit"
> which forces you to declare your variables; I'd like to see something
> similar in PHP.
>
> Apologies if this is off-topic for this list, but I'm curious as to why
> others reckon that PHP sucks.....

It's a matter of mindset. PHP and Postgres have really opposite mindsets.
Python is a lot more similar to Postgres, for instance :

- Postgres, Python : strongly typed, throws an error rather than doing
funny stuff with your data, your code does what you think it should do.
- PHP : very loosely typed, does whatever it wants, your code will
surprise you...

To stay on topic :

- There is no way to know if your persistent connection is a new
connection (so you might want to setup and issue a few PREPARE statements)
or an already "second hand" connection.
- There is no way to reconnect a dead persistent connection (if you
reboot your database server, you'll have to restart all your
webservers/PHP processes manually)
- pg_query() returns everything as strings (python/psycopg2 converts
postgres types to python types, DATE becomes datetime.datetime, arrays
too, and you can customize it)
- handling of NULL, 0, '', array(), 0.0 is horrendous
- NO DAMN UNICODE SUPPORT WTF ? (python/psycopg does the right thing)
- register_shutdown_function() isn't always called
- the object model is horrible
- no closures or lexical scoping, no first class classes or function,
strings aren't objects
- built by accretion rather than thoughtful design
- etc, etc

Still, I use it, and it works. It is always poised to bite though. You
have to wear chain mail pants with PHP.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ottavio Campana 2007-06-16 16:58:27 about cursors
Previous Message Gregory Stark 2007-06-16 16:12:21 Re: Using the power of the GPU