diff --git a/models/PhotoLinks.php b/models/PhotoLinks.php index a01bf9c..409a603 100644 --- a/models/PhotoLinks.php +++ b/models/PhotoLinks.php @@ -17,9 +17,13 @@ class PhotoLinks extends Model static function addLink($photo, $url) { $parsedUrl = parse_url($url); + $host = isset($parsedUrl['host']) ? $parsedUrl['host'] : ''; $photoDetails = explode('_', $photo); - $pointId = (int) $photoDetails[0]; - App::DB()->query('INSERT INTO photoLinks VALUES ("' . $photo . '", "' . $pointId . '","' . $url . '","' . $parsedUrl['host'] . '") ON DUPLICATE KEY UPDATE url=url;'); + $pointId = isset($photoDetails[0]) ? (int) $photoDetails[0] : 0; + + if ($pointId) { + App::DB()->query('INSERT INTO photoLinks VALUES ("' . $photo . '", "' . $pointId . '","' . $url . '","' . $host . '") ON DUPLICATE KEY UPDATE url=url;'); + } } static function getCaption($photo)