private $driver;
public $connected = false;
public $error = false;
+ public $errorno = 0;
+ public $affected_rows = 0;
private $_server_info = '';
private static $in_transaction = false;
private static $dbo;
self::$dbo->error = '';
self::$dbo->errorno = 0;
+ self::$dbo->affected_rows = 0;
switch (self::$dbo->driver) {
case 'pdo':
$retval = false;
} else {
$retval = $stmt;
+ self::$dbo->affected_rows = $retval->rowCount();
}
break;
case 'mysqli':
} else {
$stmt->store_result();
$retval = $stmt;
+ self::$dbo->affected_rows = $retval->affected_rows;
}
break;
case 'mysql':
if (mysql_errno(self::$dbo->db)) {
self::$dbo->error = mysql_error(self::$dbo->db);
self::$dbo->errorno = mysql_errno(self::$dbo->db);
+ } else {
+ self::$dbo->affected_rows = mysql_affected_rows($retval);
}
break;
}
return $retval;
}
+ /**
+ * @brief Returns the number of affected rows of the last statement
+ *
+ * @return int Number of rows
+ */
+ static public function affected_rows() {
+ return self::$dbo->affected_rows;
+ }
+
/**
* @brief Returns the number of rows of a statement
*
if (poller_passing_slow($highest_priority)) {
// Are there waiting processes with a higher priority than the currently highest?
- $result = dba::p("UPDATE `workerqueue` SET `executed` = ?, `pid` = ?
+ $result = dba::e("UPDATE `workerqueue` SET `executed` = ?, `pid` = ?
WHERE `executed` <= ? AND `priority` < ?
ORDER BY `priority`, `created` LIMIT 5",
datetime_convert(), getmypid(), NULL_DATE, $highest_priority);
- if (dbm::is_result($result)) {
- $found = (dba::num_rows($result) > 0);
+ if ($result) {
+ $found = (dba::affected_rows() > 0);
}
- dba::close($result);
if (!$found) {
// Give slower processes some processing time
- $result = dba::p("UPDATE `workerqueue` SET `executed` = ?, `pid` = ?
+ $result = dba::e("UPDATE `workerqueue` SET `executed` = ?, `pid` = ?
WHERE `executed` <= ? AND `priority` > ?
ORDER BY `priority`, `created` LIMIT 1",
datetime_convert(), getmypid(), NULL_DATE, $highest_priority);
- if (dbm::is_result($result)) {
- $found = (dba::num_rows($result) > 0);
+ if ($result) {
+ $found = (dba::affected_rows() > 0);
}
- dba::close($result);
}
}
// If there is no result (or we shouldn't pass lower processes) we check without priority limit
if (!$found) {
- $result = dba::p("UPDATE `workerqueue` SET `executed` = ?, `pid` = ? WHERE `executed` <= ? ORDER BY `priority`, `created` LIMIT 5",
+ $result = dba::e("UPDATE `workerqueue` SET `executed` = ?, `pid` = ? WHERE `executed` <= ? ORDER BY `priority`, `created` LIMIT 5",
datetime_convert(), getmypid(), NULL_DATE);
- if (dbm::is_result($result)) {
- $found = (dba::num_rows($result) > 0);
+ if ($result) {
+ $found = (dba::affected_rows() > 0);
}
- dba::close($result);
}
return $found;
}