private static function update1192()\r
{\r
// Was the script completed?\r
- if (Config::get("system", "post_update_version") >= 1192)\r
+ if (Config::get("system", "post_update_version") >= 1192) {\r
return true;\r
+ }\r
\r
// Check if the first step is done (Setting "gcontact-id" in the item table)\r
- $r = q("SELECT `author-link`, `author-name`, `author-avatar`, `uid`, `network` FROM `item` WHERE `gcontact-id` = 0 LIMIT 1000");\r
+ $r = dba::select('item', ['author-link', 'author-name', 'author-avatar', 'uid', 'network'], ['gcontact-id' => 0], ['limit' => 1000]);\r
if (!$r) {\r
// Are there unfinished entries in the thread table?\r
$r = q("SELECT COUNT(*) AS `total` FROM `thread`\r
foreach ($item_arr as $item) {\r
$gcontact_id = GContact::getId(["url" => $item['author-link'], "network" => $item['network'],\r
"photo" => $item['author-avatar'], "name" => $item['author-name']]);\r
- q("UPDATE `item` SET `gcontact-id` = %d WHERE `uid` = %d AND `author-link` = '%s' AND `gcontact-id` = 0",\r
- intval($gcontact_id), intval($item["uid"]), dbesc($item["author-link"]));\r
+ dba::update('item', ['gcontact-id' => $gcontact_id], ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'gcontact-id' => 0]);\r
}\r
return false;\r
}\r
private static function update1194()\r
{\r
// Was the script completed?\r
- if (Config::get("system", "post_update_version") >= 1194)\r
+ if (Config::get("system", "post_update_version") >= 1194) {\r
return true;\r
+ }\r
\r
logger("Start", LOGGER_DEBUG);\r
\r
private static function update1198()\r
{\r
// Was the script completed?\r
- if (Config::get("system", "post_update_version") >= 1198)\r
+ if (Config::get("system", "post_update_version") >= 1198) {\r
return true;\r
+ }\r
\r
logger("Start", LOGGER_DEBUG);\r
\r
// Check if the first step is done (Setting "author-id" and "owner-id" in the item table)\r
- $r = q("SELECT `author-link`, `owner-link`, `uid` FROM `item` WHERE `author-id` = 0 AND `owner-id` = 0 LIMIT 100");\r
+ $r = dba::select('item', ['author-link', 'owner-link', 'uid'], ['author-id' => 0, 'owner-id' => 0], ['limit' => 1000]);\r
if (!$r) {\r
// Are there unfinished entries in the thread table?\r
$r = q("SELECT COUNT(*) AS `total` FROM `thread`\r
logger("Query done", LOGGER_DEBUG);\r
\r
$item_arr = [];\r
- foreach ($r AS $item) {\r
+ foreach ($r as $item) {\r
$index = $item["author-link"]."-".$item["owner-link"]."-".$item["uid"];\r
$item_arr[$index] = ["author-link" => $item["author-link"],\r
"owner-link" => $item["owner-link"],\r
}\r
\r
// Set the "gcontact-id" in the item table and add a new gcontact entry if needed\r
- foreach ($item_arr AS $item) {\r
+ foreach ($item_arr as $item) {\r
$author_id = Contact::getIdForURL($item["author-link"], 0);\r
$owner_id = Contact::getIdForURL($item["owner-link"], 0);\r
\r
if ($owner_id == 0)\r
$owner_id = -1;\r
\r
- q("UPDATE `item` SET `author-id` = %d, `owner-id` = %d\r
- WHERE `uid` = %d AND `author-link` = '%s' AND `owner-link` = '%s'\r
- AND `author-id` = 0 AND `owner-id` = 0",\r
- intval($author_id), intval($owner_id), intval($item["uid"]),\r
- dbesc($item["author-link"]), dbesc($item["owner-link"]));\r
+ dba::update('item', ['author-id' => $author_id, 'owner-id' => $owner_id], ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'owner-link' => $item['owner-link'], 'author-id' => 0, 'owner-id' => 0]);\r
}\r
\r
logger("Updated items", LOGGER_DEBUG);\r
private static function update1206()\r
{\r
// Was the script completed?\r
- if (Config::get("system", "post_update_version") >= 1206)\r
+ if (Config::get("system", "post_update_version") >= 1206) {\r
return true;\r
+ }\r
\r
logger("Start", LOGGER_DEBUG);\r
$r = q("SELECT `contact`.`id`, `contact`.`last-item`,\r
if (!DBM::is_result($r)) {\r
return false;\r
}\r
- foreach ($r AS $user) {\r
+ foreach ($r as $user) {\r
if (!empty($user["lastitem_date"]) && ($user["lastitem_date"] > $user["last-item"])) {\r
- q("UPDATE `contact` SET `last-item` = '%s' WHERE `id` = %d",\r
- dbesc($user["lastitem_date"]),\r
- intval($user["id"]));\r
+ dba::update('contact', ['last-item' => $user['lastitem_date']], ['id' => $user['id']]);\r
}\r
}\r
\r