本文整理汇总了PHP中Model_Category::values方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Category::values方法的具体用法?PHP Model_Category::values怎么用?PHP Model_Category::values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Category
的用法示例。
在下文中一共展示了Model_Category::values方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_create
public function action_create()
{
$view = View::factory('dashboard/categories/create');
$view->roles = ORM::factory('Role')->find_all();
$this->template->content = $view->render();
if ($this->request->method() === Request::POST) {
if (!Security::check($this->request->param('id'))) {
throw new Exception("Bad token!");
}
$name = $this->request->post('name');
$description = $this->request->post('description');
$role_id = $this->request->post('role_id');
if (empty($name) and empty($description)) {
throw new Exception("Please, correct input data!");
}
$categories = new Model_Category();
$create_category = $categories->values($this->request->post())->save();
if (!$create_category) {
throw new Exception("Error with creating a category!");
}
$this->redirect('dashboard/categories/list');
}
}
示例2: action_index
public function action_index()
{
require $_SERVER['DOCUMENT_ROOT'] . "/application/vendor/vimeo/autoload.php";
$client_id = '';
$client_secret = '';
$token = '';
$token_secret = '';
$vimeo = new \Vimeo\Vimeo($client_id, $client_secret, $token);
$categories = $vimeo->request("/categories");
foreach ($categories['body']['data'] as $category) {
// $categoryArray = array('Animation', 'Arts & Design', 'Cameras & Techniques', 'Comedy', 'Documentary', 'Experimental', 'Fashion', 'Food', 'Instructionals', 'Music', 'Narrative', 'Personal', 'Reporting & Journalism', 'Sports', 'Talks'));
// if (in_array($category['name'], $categoryArray)) {
// continue;
// }
$categoryShortName = str_replace('/categories/', '', $category['uri']);
for ($i = 1; $i <= 20; $i++) {
sleep(1);
echo 'page ' . $i . ' of ' . $category['uri'];
$videos = $vimeo->request($category['uri'] . '/videos', array('sort' => 'plays', 'per_page' => 50, 'page' => $i));
// echo '<pre>'; print_r($videos); echo '</pre>'; exit;
foreach ($videos['body']['data'] as $video) {
// Prepares video data array
$videoSpecs['uri'] = $video['uri'];
$videoSpecs['name'] = $video['name'];
$videoSpecs['description'] = $video['description'];
$videoSpecs['link'] = $video['link'];
$videoSpecs['duration'] = $video['duration'];
$videoSpecs['width'] = $video['width'];
$videoSpecs['height'] = $video['height'];
$videoSpecs['create_time'] = $video['created_time'];
$videoSpecs['plays'] = $video['stats']['plays'];
$videoSpecs['likes'] = $video['metadata']['connections']['likes']['total'];
$videoSpecs['comments'] = $video['metadata']['connections']['comments']['total'];
if ($video['privacy']['embed'] === 'public') {
$videoSpecs['embeddable'] = true;
} else {
$videoSpecs['embeddable'] = false;
}
// Look for existing record
$videoOrm = ORM::factory('Video')->where('uri', '=', $video['uri'])->find_all()->as_array();
if (sizeOf($videoOrm) === 0) {
// Add record to DB if it doesn't exist
$videoRecord = new Model_Video();
$videoRecord->values($videoSpecs);
$videoRecord->save();
$videoId = $videoRecord->id;
$videoOrm = ORM::factory('Video')->where('uri', '=', $video['uri'])->find();
// Populate tags table with video data
foreach ($video['tags'] as $tag) {
$tagRecord = new Model_Tag();
$tagRecord->values(array('video_id' => $videoId, 'name' => $tag['name']));
$tagRecord->save();
}
} else {
// Update record if it exists
$videoOrm[0]->values($videoSpecs);
$videoOrm[0]->save();
$videoId = $videoOrm[0]->id;
}
// Populate categories table category data if that video and category association is not already stored
$categoryOrm = ORM::factory('Category')->where('video_id', '=', $videoId)->and_where('short_name', '=', $categoryShortName)->find_all();
if ($categoryOrm->count() === 0) {
$categoryRecord = new Model_Category();
$categoryRecord->values(array('video_id' => $videoId, 'name' => $category['name'], 'short_name' => $categoryShortName));
$categoryRecord->save();
}
}
}
}
}