You are here: Excellent language PHP5 is! « PHP « IT news, forums, messages
Excellent language PHP5 is!

Posted by "Robert Meyer" on 11/26/88 11:16

Hello All,

Just a comment on PHP5. I never used PHP until just over two weeks ago,
though I have been a software engineer since 1975. What one can do with
PHP5 is awesome.

I have just developed and tested a function where all SIMPLE access to the
MySQL database is contained therein. I just pass to this function the
appropriate parameters. I do INSERTs, UPDATEs, DELETEs, and SELECTs with
it. What makes this all possible are the following abilities of the PHP5
language (not in any particular order):

1) explode
2) isset
3) variable variables (subscripted even): ${$_O[1]}
4) ability to make variable variables global: global ${$_O[1]};
5) variable number of parameters: func_num_args(), func_get_arg()
6) the passing of arrays as parameters
7) dynamically create PHP5 code to execute with the eval() function

Example usage of my function:

1) if (MySQL_Action('I,0,3','MyTable','','Fld1Name','Fld1Value,'Fld2Name','Fld2Value'))
{ . . . }
The above inserts two fields into MyTable and returns True if it succeeds.

2) if (MySQL_Action('S,0,3','MyTable','RecId =
'.$RecId,'Fld1Name','GlobalVar4Value')) { . . . }
The above selects the record where RecId = $RecId and assigns the value in
Fld1Name to the global variable $GlobalVar4Value and returns True if it
succeeds.

3) if (MySQL_Action('U,0,3','MyTable',"RecId = $RecId",'Fld1Name','Fld1Value'))
{ . . . }
The above updates the record where RecId = $RecId SETting Fld1Name =
Fld1Value and returns True if it succeeds.

4) if (MySQL_Action('S:R,0,3','MyTable','1 ORDER BY OrderIt, RecId','*'))
{ . . . }
The above SELECTs all fields (*) from MyTable in the order of OrderIt, RecId
and assigns the result of the mysql_query to the global variable $R and
returns True if it succeeds. The R in 'S:R' can be anything, such as
'S:MyResult' and is used for other mysql functions such as
mysql_num_rows($R) or mysql_fetch_row($MyResult) after calling this
function.

This function turns several lines of code into one line and takes care of
correctly formatting the SQL statement.

There is one thing I hope is implemented in PHP soon. That is the ability
to pass by reference and receive the reference in variable parameter lists.
You can pass by reference to a function taking a variable number of
parameters, but func_get_arg() only returns the value and therefore, any
changes to that variable do not change the variable as seen by the caller.
Maybe a func_get_refarg() could be implemented.

Over all, an Excellent language PHP5 is!

Regards,

Robert

 

Navigation:

[Reply to this 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

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