本文整理汇总了PHP中Album::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::save方法的具体用法?PHP Album::save怎么用?PHP Album::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showSeedAlbum
public function showSeedAlbum()
{
$album = new Album();
$album->title = 'Some Mad Hope';
$album->artist = 'Matt Nathanson';
$album->genre = 'Acoustic Rock';
$album->year = 2007;
$album->save();
$album = new Album();
$album->title = 'Please';
$album->artist = 'Matt Nathanson';
$album->genre = 'Acoustic Rock';
$album->year = 1993;
$album->save();
$album = new Album();
$album->title = 'Leaving Throught The Window';
$album->artist = 'Something Corp';
$album->genre = 'Piano Rock';
$album->year = 2002;
$album->save();
$album = new Album();
$album->title = '...Anywhere But here';
$album->artist = 'Something Corp';
$album->genre = 'Punk Rock';
$album->year = 1997;
$album->save();
$album = new Album();
$album->title = '...Is A Real Boy';
$album->artist = 'Something Corp';
$album->genre = 'Indie Rock';
$album->year = 2006;
$album->save();
}
示例2: actionCreate
public function actionCreate()
{
$model = new Album();
if (isset($_POST['Album']) || isset($_POST['Page'])) {
if (isset($_POST['Album'])) {
$model->setAttributes($_POST['Album']);
}
if (isset($_POST['Album']['page'])) {
$model->page = $_POST['Album']['page'];
}
if (isset($_POST['Album']['thumbnail'])) {
$model->thumbnail = $_POST['Album']['thumbnail'];
}
try {
if ($model->save()) {
if (isset($_GET['returnUrl'])) {
$this->redirect($_GET['returnUrl']);
} else {
$this->redirect(array('view', 'id' => $model->id));
}
}
} catch (Exception $e) {
$model->addError('', $e->getMessage());
}
} elseif (isset($_GET['Album'])) {
$model->attributes = $_GET['Album'];
}
$this->render('create', array('model' => $model));
}
示例3: store
public function store()
{
$data = Input::all();
$album = new Album();
$album['title'] = $data['title'];
$album['user_id'] = Session::get('user')['id'];
$album['privacy'] = $data['privacy'];
$file = Input::file('img');
$folder_user = Session::get('user')['account'];
$album_path = 'public/upload/' . $folder_user . '/' . uniqid(date('ymdHisu'));
foreach ($file as $key => $f) {
$name = uniqid() . "." . $f->getClientOriginalExtension();
$f->move($album_path, $name);
if ($key == 0) {
// $album['album_img'] = $name;
$album->save();
FEEntriesHelper::save($album->id, FEEntriesHelper::getId("Album"), $album->user_id, $album->privacy);
}
$path = $album_path . '/' . $name;
$image = new Image();
$image['path'] = $path;
$image['user_id'] = Session::get('user')['id'];
$image['album_id'] = $album['id'];
$image['width'] = getimagesize($path)[0];
$image['height'] = getimagesize($path)[1];
$image->save();
}
echo json_encode($file);
}
示例4: unpublishSubalbums
function unpublishSubalbums($album)
{
global $gallery;
$albums = $album->getAlbums();
foreach ($albums as $albumname) {
$subalbum = new Album($gallery, $albumname);
$subalbum->setShow(false);
$subalbum->save();
unpublishSubalbums($subalbum);
}
}
示例5: set_album
public function set_album($album_str)
{
if (!Albums::get_by_name($album_str)) {
$album = new Album();
$album->set_name($album_str);
$album->save();
} else {
$album = Albums::get_by_name($album_str);
}
$this->music_album = $album->get_id();
}
示例6: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Album();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Album'])) {
$model->attributes = $_POST['Album'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例7: testCreateAlbum
/**
* TC12: Create operation on Albums
* Test to verify that the database can save new albums
* The test is performed by creating an album object with the required input fields
* Once the test is complete no errors will appear and the album will be in the database
*/
public function testCreateAlbum() {
//Create the album
$album = new Album();
$album['artist_id'] = $this->artist['artist_id'];
$album['name'] = 'testalbum2';
$album['added_by_user_id'] = 1; //SYSTEM user
$album->save();
//Verify it exist now
$this->assertTrue($album->exists());
}
示例8: postCreate
public function postCreate()
{
//Todo: validate
$name = $_POST['name'];
if ($name === '') {
return View::make('albums.create');
}
$album = new Album();
$album->name = $name;
$album->owner_id = Auth::user()->id;
$album->save();
return Redirect::to('/albums/own');
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$rules = ['nama' => 'required'];
$pesan = ['nama.required' => 'Nama harus diisi'];
$validasi = Validator::make(Input::all(), $rules, $pesan);
if ($validasi->fails()) {
return Redirect::back()->withErrors($validasi);
} else {
$album = new Album();
$album->nm_album = Input::get('nama');
$album->created_by = Sentry::getUser()->username;
$album->save();
$theId = DB::getPdo()->lastInsertId();
return Redirect::to('admin/gallery/' . $theId . '/tambahfoto');
}
}
示例10: updateAlbum
public function updateAlbum(Album $album)
{
$inputs = ['name' => Input::get('name'), 'description' => Input::get('description'), 'user_id' => Input::get('uid')];
$valid = Validator::make($inputs, Album::$rules);
if ($valid->passes()) {
$album->name = $inputs['name'];
$album->description = $inputs['description'];
$album->user_id = $inputs['user_id'];
if (count($album->getDirty()) > 0) {
$album->save();
return Redirect::back()->with('success', Lang::choice('messages.Albums', 1) . ' ' . trans('messages.is updated'));
} else {
return Redirect::back()->with('success', trans('messages.Nothing to update'));
}
} else {
return Redirect::back()->withErrors($valid)->withInput();
}
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$data = Input::except(array('_token', '_method'));
$trimmedData = $this->trimData($data, array());
$album = Album::where('name', $trimmedData['name'])->get()->first();
if (!empty($album)) {
Session::flash('flash_error', trans('message.album.error.already_exist'));
return Redirect::route('secured.album.create')->withInput();
}
$currentUser = $this->getCurrentUser();
$album = new Album();
$album->fill($trimmedData);
$album->owner_id = $currentUser->id;
if (!$album->save()) {
$errors = $album->errors();
return Redirect::route('secured.album.create')->withInput()->withErrors($errors);
}
return Redirect::route('secured.album.index');
}
示例12: checkAlbumParentid
function checkAlbumParentid($albumname, $id)
{
global $gallery;
$album = new Album($gallery, $albumname);
$oldid = $album->get('parentid');
if ($oldid !== $id) {
$album->set('parentid', $id);
$album->save();
if (is_null($oldid)) {
$oldid = '<em>NULL</em>';
}
if (is_null($id)) {
$id = '<em>NULL</em>';
}
printf('Fixed album <strong>%1$s</strong>: parentid was %2$s should have been %3$s<br />', $albumname, $oldid, $id);
}
$id = $album->id;
$albums = $album->getSubalbums();
foreach ($albums as $albumname) {
checkAlbumParentid($albumname, $id);
}
}
示例13: actionCreate
/**
* Creates a new album with optional album cover.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$user = $this->getUser();
if ($user->id != Yii::app()->user->id) {
throw new CHttpException(403, 'You can create album only on your profile.');
}
$this->subLayout = "application.modules.album.views._layout";
$model = new Album();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Album'])) {
$_POST = Yii::app()->input->stripClean($_POST);
$_POST['containerGuid'] = Yii::app()->user->guid;
$_POST['containerClass'] = 'User';
$model->content->populateByForm();
$model->attributes = $_POST['Album'];
if ($model->save()) {
PublicFile::attachPrecreated($model, Yii::app()->request->getParam('cover'));
$this->redirect(['/album/view', 'id' => $model->id, 'username' => $user->username, 'uguid' => $user->guid]);
}
}
$this->render('/album/create', ['model' => $model, 'user' => $user]);
}
示例14: saveAlbum
public function saveAlbum()
{
$validator = Validator::make(Input::all(), array('album_title' => 'required|unique:albums,title'));
if ($validator->fails()) {
return Redirect::route('edit-albums')->withInput()->withErrors($validator)->with('modal', '#album_form');
} else {
$album = new Album();
$album->title = Input::get('album_title');
$album->release = Input::get('album_release');
$slug = strtolower(Input::get('album_title'));
//Make alphanumeric (removes all other characters)
$slug = preg_replace("/[^a-z0-9_\\s-]/", "", $slug);
//Clean up multiple dashes or whitespaces
$slug = preg_replace("/[\\s-]+/", " ", $slug);
//Convert whitespaces and underscore to dash
$slug = preg_replace("/[\\s_]/", "-", $slug);
$album->slug = $slug;
if ($album->save()) {
return Redirect::route('edit-albums')->with('success', 'The album was added.');
} else {
return Redirect::route('edit-albums')->with('fail', 'An error occured while saving the new album.');
}
}
}
示例15: addAlbum
/**
* Add an Album to the database or get its key if it exists
* @param name str: the name of the album to add
* @return int: the primary key added or found
*/
public function addAlbum($name)
{
//is this name already in the collection?
$q = Doctrine_Query::create()->select('a.id')->from('Album a')->where('a.name = ?', $name);
$result = $q->fetchOne();
if (is_object($result) && $result->id > 0) {
$retId = $result->id;
unset($q, $result);
return (int) $retId;
} else {
$item = new Album();
$item->name = $name;
if ($name == 'Unknown Album') {
$item->has_art = 1;
//there's no point scanning an unknown album for art
}
$item->scan_id = 1;
$item->save();
$id = $item->getId();
$item->free();
unset($item, $q, $result);
return (int) $id;
}
}