From 6ba76ab818d0d6e9b30479e0233c5e7f22bb50cd Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Thu, 7 Jan 2016 14:41:45 +0300 Subject: [PATCH] =?UTF-8?q?FIX=20-=20=D0=BC=D0=B5=D0=BB=D0=BA=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D0=B8=20?= =?UTF-8?q?=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B8=20=D0=BD=D0=B0=20=D0=B8?= =?UTF-8?q?=D1=81=D1=85=D0=BE=D0=B4=D0=BD=D1=83=D1=8E=20=D1=84=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/PhotoLinks.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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)