note 58250 deleted from ref.mysqli by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 17:23:34 +0000 |
| Subject: | note 58250 deleted from ref.mysqli by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133162@lists.php.net to get a copy of this message | ||
Note Submitter: dgbaley27 at comcast dot net
----
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.