You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when try to search anything, nothing shows, and apache log error:
PHP Fatal error: Call to a member function fetch_array() on boolean in /var/www/html/inc/dbmysql.class.php on line 282, referer: http ://xx.xx.xx.xx/plugins/physicalinv/front/inventory.php
$result = $DB->query($query);
while ($data = $DB->fetch_array($result)) {
if ($item->canEdit($data['id'])) {
$id_list[$itemtype][$data['id']] = $data['id'];
}
}
fixed code:
$result = $DB->query($query);
if ($DB->numrows($result)>0) {
while ($data = $DB->fetch_array($result)) {
if ($item->canEdit($data['id'])) {
$id_list[$itemtype][$data['id']] = $data['id'];
}
}
}
I hope this helps (it worked for me).
EDIT: I investigated further, using Generic Object plugin caused error. To make both plugins work together few more changes need to be done. Reason: not all object need to have dustbin and template fields.
/**
* Search and get list of devices have the 'number' in serial number or
* inventory number
*
* @param string $number
* @return array
*/
function searchItemWithNumber($number) {
global $DB, $CFG_GLPI;
$id_list = array();
// search in inventory have serial number or inventory number
foreach($CFG_GLPI["asset_types"] as $itemtype) {
$where_fields = array();
$table = getTableForItemType($itemtype);
$item = new $itemtype();
if (FieldExists($table, 'serial')) {
$where_fields[] = 'serial';
}
if (FieldExists($table, 'otherserial')) {
$where_fields[] = 'otherserial';
}
if (count($where_fields) == 0) {
continue;
}
$query = "SELECT *
FROM `".$table."` WHERE (";
$first = True;
foreach ($where_fields as $field) {
if (!$first) {
$query .= " OR ";
}
$query .= " `$field`='$number'";
$first = False;
}
$query .= ")";
if (FieldExists($table, 'is_deleted')) { // only if dust bin enabled
$query .= " AND `is_deleted`='0'";
}
if (FieldExists($table, 'is_template')) { // only if templates are in use
$query .= " AND `is_template`='0'";
}
$result = $DB->query($query);
if ($DB->numrows($result)>0) {
while ($data = $DB->fetch_array($result)) {
if ($item->canEdit($data['id'])) {
$id_list[$itemtype][$data['id']] = $data['id'];
}
}
}
}
return $id_list;
}
Regards
Rafal
The text was updated successfully, but these errors were encountered:
Rafit77
changed the title
when using with GLPI 9.1.2 (latest) - PHP fatal error
when using with Generic Object plugin - PHP fatal error
Mar 7, 2019
when try to search anything, nothing shows, and apache log error:
problem:
file: /plugins/physicalinv/inc/inventory.class.php
code:
fixed code:
I hope this helps (it worked for me).
EDIT: I investigated further, using Generic Object plugin caused error. To make both plugins work together few more changes need to be done. Reason: not all object need to have dustbin and template fields.
Regards
Rafal
The text was updated successfully, but these errors were encountered: