本文整理汇总了PHP中Album::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::insert方法的具体用法?PHP Album::insert怎么用?PHP Album::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action
function action()
{
$category = new Category();
$kdgs = new Kdgs();
$album = new Album();
$story_url = new StoryUrl();
$category_list = $category->get_list("`res_name`='kdgs' and `s_id`='0'");
foreach ($category_list as $k => $v) {
$page = 1;
while (true) {
$album_list = $kdgs->get_children_category_album_list($v['s_p_id'], $page);
if (!$album_list) {
break;
}
foreach ($album_list as $k2 => $v2) {
$exists = $album->check_exists("`link_url` = '{$v2['url']}'");
if ($exists) {
continue;
}
$album_id = $album->insert(array('title' => $v2['title'], 'min_age' => $v2['min_age'], 'max_age' => $v2['max_age'], 'intro' => '', 's_cover' => $v2['cover'], 'link_url' => $v2['url'], 'add_time' => date('Y-m-d H:i:s')));
$story_url->insert(array('res_name' => 'album', 'res_id' => $album_id, 'field_name' => 'cover', 'source_url' => $v2['cover'], 'source_file_name' => ltrim(strrchr($v2['cover'], '/'), '/'), 'add_time' => date('Y-m-d H:i:s')));
}
$page++;
}
}
}
示例2: postCreate
public function postCreate()
{
if (Auth::guest()) {
return Redirect::secure('user/login');
}
// do not use layout for this
$this->layout = null;
// add to db
Input::get('isPrivate') == 1 ? $isPrivate = 1 : ($isPrivate = 0);
Album::insert(array('user_id' => Input::get('userId'), 'categories_id' => Input::get('category'), 'name' => strip_tags(Purifier::clean(Input::get('name'))), 'isPrivate' => $isPrivate));
// redirect to albums
return Redirect::secure('user/albums');
}
示例3: create
/**
* Create new Album
*
* Also updates Category modification time
*
* @param int $categoryId
*/
public function create($categoryId)
{
$category = $this->getCategoryFinder()->findOneBy('id', $categoryId);
if ($this->slim->request->isGet()) {
$this->slim->render('album/create.html.twig', ['category' => $category, 'sessionUser' => $this->getSessionUser()]);
} elseif ($this->slim->request->isPost()) {
$name = $_POST['name'];
$newAlbum = new Album($this->slim->db);
$newAlbum->setCategoryId($category->getId());
$newAlbum->setName($name);
$newAlbum->insert();
$category->update();
$this->slim->flash('success', 'Album created');
$this->slim->redirect('/categories/' . $categoryId . '/albums');
}
}