RE: [PHP] PHP database syntax/construct: can we make it better?

From: Date: Tue, 11 Jul 2000 23:29:19 +0000
Subject: RE: [PHP] PHP database syntax/construct: can we make it better?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-6038@lists.php.net to get a copy of this message
One thing I have noticed with PHP is that object vs. procedural implementation causes some of the confusion in these discussions. All of the PHP libs seem to be procedural; Most of the _abstractions_ seem to be object based. And there seem to be some "mine's the best abstraction class!" going on. There are so many abstraction classes available in user space, that just about anyone should be able to find one close their liking. And it is pretty easy to write your own that meets your specific requirement. Both of these reasons are why there is not much inertia behind a lower level database abstraction lib. A general procedural database library is difficult to write because the variety of databases have different interfaces and feature mixes. A general procedural SQL library (which would also be very helpful to many) is also difficult to write for the same reasons. > -----Original Message----- > From: mohrt@ispi.net [mailto:mohrt@ispi.net]On Behalf Of Monte Ohrt > Sent: Tuesday, July 11, 2000 2:00 PM > To: php-general@lists.php.net; php-dev@lists.php.net > Subject: [PHP] PHP database syntax/construct: can we make it better? > > > One thing about PHP that has always been kind of difficult is the way it > accesses databases. I'm not necessarily talking about abstraction, but > the way the syntax works which is mostly inherited from the PHP language > structure. > > Here is an example of what I mean. I'll give one example of how PHP does > a database query, and then a comparison to the way another "html-ish" > scripting language accomplishes the same task. > > Example: selecting and displaying rows from a database. > > ---PHP:--- > > <? > > $link = mysql_connect("my_host","my_name","my_pass"); > mysql_select_db("my_db",$link); > > $result = mysql_query("select first,last,addr from > my_table",$link); > > while($row = mysql_fetch_row($result) { > printf("%s, %s, %s<br>\n",$row[0],$row[1],$row[2]); > } > > echo "there were ".mysql_num_rows($result)." records > found.<br>\n"; > > ?> > > > ---OTHER HTML-TYPE LANGUAGE:--- > > > <HOST = "my_host"> > <USER = "my_name"> > <PASS = "my_pass"> > <DB = "my_db"> > > <SQL "select first,last,addr from my_table"> > $first, $last, $addr<br> > </SQL> > There were $loop records found. > > > > > Of course each syntax has it's pros and cons. PHP is much more > extensible, but the latter is quite easy to read and quick to implement > without the need to construct for() and while() loops. Is there any way > to make PHP a bit easier to work with, instead of constantly having to > create while loops, calling functions for simple things like number of > rows fetched, etc.? Any good way to implicitly automate this? > > I have some ideas, but they require modifying the fundamental PHP > language construct. > > I have attached those thoughts below. Any other ideas, or do we just > deal with what we have? > > Monte

« previous php.general (#6038) next »