note 58250 added to ref.mysqli
| From: | dgbaley27 at comcast dot net | Date: | Fri, 28 Oct 2005 20:06:25 +0000 |
| Subject: | note 58250 added to ref.mysqli | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-97768@lists.php.net to get a copy of this message | ||
I wrote the following mysqli extension to make it a little easier to pull data for some peope. It
combines the query() and fetch_assoc() methods:
<?
class Sql extends mysqli {
function __construct($host, $user, $password, $table) {
parent::__construct($host, $user, $password, $table);
}
function data($SQL, $force=0) {
static $holdQuery;
static $result;
if ($SQL != $holdQuery) {
$result = $this->query($SQL);
$holdQuery = $SQL;
}
return $result->fetch_assoc();
}
}
?>
So to implement:
<?
$link = new Sql("host", "user", "password", "table");
$SQL = "SELECT * FROM anyTable";
while ($row = $link->data($SQL)) {
// manipulate data
}
?>
This can be very much expanded upon but I'm a freak for minimal code and I'm sure there
are pleanty of you out there like me.
----
Manual Page -- http://www.php.net/manual/en/ref.mysqli.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58250
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58250&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58250&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58250&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58250&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58250&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58250&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58250&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58250&report=yes
Search -- http://master.php.net/manage/user-notes.php