* @param string|array $table Table name or array [schema => table]
* @param array $fields contains the fields that are updated
* @param array $condition condition array with the key values
- * @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate)
+ * @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate, false = don't update identical fields)
*
* @return boolean was the update successfull?
* @throws \Exception
$row = $this->fetchFirst($sql, $condition);
- // Ensure to always return either a "null" or a numeric value
- return is_numeric($row['count']) ? (int)$row['count'] : $row['count'];
+ if (!isset($row['count'])) {
+ $this->logger->notice('Invalid count.', ['table' => $table, 'row' => $row, 'expression' => $expression, 'condition' => $condition_string, 'callstack' => System::callstack()]);
+ return 0;
+ } else {
+ return (int)$row['count'];
+ }
}
/**