protected function Dbug::varIsDbResource in dBug for Drupal 2.0.x
Same name and namespace in other branches
- 8 src/Dbug.php \Drupal\dbug\Dbug::varIsDbResource()
- 1.0.x src/Dbug.php \Drupal\dbug\Dbug::varIsDbResource()
If variable is a database resource type.
Parameters
mixed $var: The variable.
string $db: The database.
1 call to Dbug::varIsDbResource()
- Dbug::varIsResource in src/
Dbug.php - If variable is a resource type.
File
- src/
Dbug.php, line 487
Class
- Dbug
- Implementation of dBug for Drupal.
Namespace
Drupal\dbugCode
protected function varIsDbResource($var, $db = "mysql") {
if ($db == "pgsql") {
$db = "pg";
}
if ($db == "sybase-db" || $db == "sybase-ct") {
$db = "sybase";
}
$arrFields = [
"name",
"type",
"flags",
];
$numrows = call_user_func($db . "_num_rows", $var);
$numfields = call_user_func($db . "_num_fields", $var);
$this
->makeTableHeader("resource", $db . " result", $numfields + 1);
$this->output[] = "<tr><td class=\"dBug_resourceKey\"> </td>";
for ($i = 0; $i < $numfields; $i++) {
$field_header = "";
for ($j = 0; $j < count($arrFields); $j++) {
$db_func = $db . "_field_" . $arrFields[$j];
if (function_exists($db_func)) {
$fheader = call_user_func($db_func, $var, $i) . " ";
if ($j == 0) {
$field_name = $fheader;
}
else {
$field_header .= $fheader;
}
}
}
$field[$i] = call_user_func($db . "_fetch_field", $var, $i);
$this->output[] = "<td class=\"dBug_resourceKey\" title=\"" . $field_header . "\">" . $field_name . "</td>";
}
$this->output[] = "</tr>";
for ($i = 0; $i < $numrows; $i++) {
$row = call_user_func($db . "_fetch_array", $var, constant(strtoupper($db) . "_ASSOC"));
$this->output[] = "<tr>\n";
$this->output[] = "<td class=\"dBug_resourceKey\">" . ($i + 1) . "</td>";
for ($k = 0; $k < $numfields; $k++) {
$field_row = $row[$field[$k]->name];
$field_row = $field_row == "" ? "[empty string]" : $field_row;
$this->output[] = "<td>" . $field_row . "</td>\n";
}
$this->output[] = "</tr>\n";
}
$this->output[] = "</table>";
if ($numrows > 0) {
call_user_func($db . "_data_seek", $var, 0);
}
}