X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FItemURI.php;h=460ee1447004becb635d059fb63fd2705515748b;hb=2e05dac7dae0a3d028b442a2d5afbd4176a32e99;hp=12e8d915df2cfe88ff4ca2e92cc69907e53757a0;hpb=98b3058601054fcb9f330a6990745fef8f1c3e1f;p=friendica.git diff --git a/src/Model/ItemURI.php b/src/Model/ItemURI.php index 12e8d915df..460ee14470 100644 --- a/src/Model/ItemURI.php +++ b/src/Model/ItemURI.php @@ -1,6 +1,6 @@ $uri])) { - DBA::insert('item-uri', $fields, true); + DBA::insert('item-uri', $fields, Database::INSERT_UPDATE); } $itemuri = DBA::selectFirst('item-uri', ['id', 'guid'], ['uri' => $uri]); @@ -75,6 +76,27 @@ class ItemURI return self::insert(['uri' => $uri]); } + return $itemuri['id']; + } + /** + * Searched for an id of a given guid. + * + * @param string $guid + * + * @return integer item-uri id + * @throws \Exception + */ + public static function getIdByGUID($guid) + { + // If the GUID gets too long we only take the first parts and hope for best + $guid = substr($guid, 0, 255); + + $itemuri = DBA::selectFirst('item-uri', ['id'], ['guid' => $guid]); + + if (!DBA::isResult($itemuri)) { + return 0; + } + return $itemuri['id']; } }