本文整理汇总了PHP中Movie::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Movie::insert方法的具体用法?PHP Movie::insert怎么用?PHP Movie::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Movie
的用法示例。
在下文中一共展示了Movie::insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert_video_type
/**
* Insert video for derived type.
* @param array $data
* @param array $gtypes
* @param array $options
* @return int
*/
private static function insert_video_type(array $data, $gtypes, $options = array())
{
if (count($gtypes) > 0) {
$gtype = $gtypes[0];
switch ($gtype) {
case 'tvshow':
return TVShow_Episode::insert($data, $gtypes, $options);
case 'movie':
return Movie::insert($data, $gtypes, $options);
case 'clip':
return Clip::insert($data, $gtypes, $options);
case 'personal_video':
return Personal_Video::insert($data, $gtypes, $options);
default:
// Do nothing, video entry already created and no additional data for now
break;
}
}
return $data['id'];
}
示例2: parseMovie
public function parseMovie($movie_array)
{
$movie = new Movie();
$movie->setMovie($movie_array);
if ($movie->exists()) {
if ($movie->requiresUpdate()) {
$movie->update();
} else {
echo "OK - ID: " . $movie->id . "; Modified: " . $movie->modified . "<br>";
}
} else {
$movie->insert();
}
if ($movie_array->venues->children()) {
Movie::parseMovieVenues($movie_array['movieId'], $movie_array->venues);
}
}
示例3: curl_init
<?php
include __DIR__ . '/init.inc.php';
$top_url = 'http://itunes.apple.com/tw/genre/dian-ying/id33?l=zh';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $top_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, 0);
$message = curl_exec($curl);
curl_close($curl);
if (!preg_match_all('#<a href="([^"]*)" class="top-level-genre" title="[^"]*">[^<]*</a>#', $message, $matches)) {
die('failed');
}
foreach ($matches[1] as $genre_url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $genre_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, 0);
$message = curl_exec($curl);
curl_close($curl);
preg_match_all('#<li><a href="(http://itunes.apple.com/tw/movie/[^/]*/id([0-9]+)\\?l=zh)">([^<]*)</a> </li>#', $message, $matches);
foreach ($matches[0] as $id => $data) {
$url = $matches[1][$id];
$movie_id = $matches[2][$id];
$movie_name = $matches[3][$id];
if (Movie::find($movie_id)) {
continue;
}
Movie::insert(array('id' => $movie_id, 'url' => $url, 'description' => $movie_name, 'created_at' => time()));
}
}