span style="color: #0000BB"><?php $video_sql = []; $id_sql_select = []; $timestamp = time(); foreach ($videos as $video) { $id_sql_select[] = "'{$video['id']}'"; $description = $db->real_escape_string($video['description']); $title = $db->real_escape_string($video['title']); $video_sql[$video['id']] = "('{$video['id']}', \"$title\", \"$description\", 1, " . "{$video['duration']}, $timestamp)"; } $q_select = "SELECT `id` FROM `$this->_tableName` WHERE `id` IN (".implode(', ', $id_sql_select) . ")"; if ($r = $db->query($q_select)) { while($row = $r->fetch_assoc()) unset($video_sql[$row['id']]); } if (sizeof($video_sql)) { $q = "INSERT INTO `$this->_tableName` (`id`, `title`, `description`, `description_mini`, `duration`, `timestamp`)\n" . "VALUES ". implode(",\n", $video_sql); if (!$db->query($q)) { echo $db->error; return false; } } |