note 55949 added to ref.mysql
| From: | DGBaley27$A$T$comcast$D$O$T$-n-e-t- at osu1 dot php dot net | Date: | Thu, 18 Aug 2005 18:22:38 +0000 |
| Subject: | note 55949 added to ref.mysql | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93851@lists.php.net to get a copy of this message | ||
I find the following functions helpful in all my php/mysql applications:
function sql($SQL, $db='default') {
$link = mysql_connect($MySQL_Server, $MySQL_User, $MySQL_PW);
mysql_select_db($db, $link);
$result = mysql_query($SQL, $link);
mysql_close($link);
return $result;
} // end sql()
function sqlOne($SQL, $db) {
$result = sql($SQL, $db);
$row = mysql_fetch_array($result);
return $row;
} // end sqlOne()
function sqlOneField($field, $SQL, $db) {
$result = sqlOne($SQL, $db);
$row = mysql_fetch_array($result);
return $row[$field];
} // end sqlOneField()
//Each function builds on the next and provides quick access to a result resource, table row, or
specific field respectively.
//This assures that all links to the database are closed.
----
Manual Page -- http://www.php.net/manual/en/ref.mysql.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55949
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55949&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55949&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55949&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55949&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55949&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55949&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55949&report=yes
Search -- http://master.php.net/manage/user-notes.php