本文整理汇总了PHP中Album::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::model方法的具体用法?PHP Album::model怎么用?PHP Album::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Album the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Album::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested album does not exist.');
}
return $model;
}
示例2: unlinkAlbumFromArtist
protected function unlinkAlbumFromArtist($albumid)
{
$sql = "DELETE FROM artist_album WHERE album_id=:album_id";
$command = Album::model()->getDbConnection()->createCommand($sql);
$command->bindValues(array(":album_id" => $albumid));
$command->execute();
return true;
}
示例3: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Album the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$user = $this->getUser();
$model = Album::model()->findByAttributes(['id' => $id, 'created_by' => $user->id]);
if ($model === null) {
throw new CHttpException(404, 'The requested album does not exist.');
}
return $model;
}
示例4: run
public function run()
{
$st = 'Music[artist_id]';
echo "<option>" . $_GET[$st] . "</option>";
exit;
$data = Album::model()->findAll('artist_id=:artist_id', array(':artist_id' => (int) $_GET['Music[artist_id]']));
$data = CHtml::listData($data, 'id', 'name');
foreach ($data as $value => $name) {
echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
}
}
示例5: actionIndex
public function actionIndex($id)
{
$model = Album::model()->findByAttributes(['id' => $id, 'created_by' => Yii::app()->user->id]);
if ($model === null) {
throw new CHttpException(404, 'The requested album does not exists.');
}
$this->subLayout = "application.modules.album.views._layout";
$criteria = new CDbCriteria(['condition' => 'album_id = ' . $model->id, 'with' => 'image']);
$dataProvider = new CActiveDataProvider('AlbumImage', ['criteria' => $criteria]);
$this->render('/album/details', ['model' => $model, 'dataProvider' => $dataProvider]);
}
示例6: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
*/
public function loadModel()
{
if ($this->_model === null) {
if (isset($_GET['id'])) {
$this->_model = Album::model()->findbyPk($_GET['id']);
}
if ($this->_model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
}
return $this->_model;
}
示例7: getOne
public function getOne($keyid, $return = '')
{
if (!$keyid) {
return false;
}
$info = Album::model()->findByPk($keyid);
if (!$info) {
return false;
}
if ($return != '') {
return $info[$return];
} else {
return $info;
}
}
示例8: actionIndex
function actionIndex()
{
//首页幻灯片展示,读取最新4条
$ppt = Article::model()->findAll(array('order' => 'create_time desc', 'limit' => 4));
//首页最新微语展示
$wei = Weiyu::model()->findAll(array('order' => 'create_time desc'));
// 首页点击率思想展示
$sixiang = Article::model()->findAll(array('order' => 'click desc', 'limit' => 8));
// 首页得瑟会员、小丫丫展示
$jiaoya = User::model()->findAll(array('order' => 'regtime desc', 'limit' => 5));
//首页展示标签
$pictag = Albumcate::model()->findAll();
$articletag = Type::model()->findAll();
//首页展示新的图
$likepic = Album::model()->findAll(array('order' => 'create_time desc', 'limit' => 9));
$data = array('quote' => $this->getRandomQuote(), 'ppt' => $ppt, 'wei' => $wei, 'sixiang' => $sixiang, 'jiaoya' => $jiaoya, 'pictag' => $pictag, 'likepic' => $likepic, 'articletag' => $articletag);
$this->render('index', $data);
}
示例9: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($id)
{
$album = Album::model()->findByPk($id);
if ($album === null) {
throw new CHttpException(404, 'The requested album does not exists.');
}
$model = new AlbumImage();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['AlbumImage'])) {
$model->attributes = $_POST['AlbumImage'];
$model->album_id = $album->id;
if ($model->save()) {
PublicFile::attachPrecreated($model, $model->_image);
$this->redirect(['/album/details', 'id' => $album->id]);
}
}
$this->render('create', ['model' => $model, 'album' => $album]);
}
示例10: run
public function run()
{
$model = new Music();
if (isset($_GET['artist_id'])) {
$model->artist_id = (int) $_GET['artist_id'];
} elseif (isset($_GET['album_id'])) {
$album_id = (int) $_GET['album_id'];
$album_info = Album::model()->findByPk($album_id);
$model->artist_id = $album_info->artist_id;
$model->album_id = $album_id;
}
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Music'])) {
$model->attributes = $_POST['Music'];
$model->musicfile = CUploadedFile::getInstance($model, 'musicfile');
if ($model->save()) {
$this->redirect(array('admin'));
}
}
$this->render('create', array('model' => $model));
}
示例11: count
<li class="list"><a href="<?php
echo Yii::app()->createUrl('backend/weiyu/index');
?>
">微语: <?php
echo count(Weiyu::model()->findAll());
?>
句</a></li>
<li class="list"><a href="<?php
echo Yii::app()->createUrl('backend/user/index');
?>
">注册会员: <?php
echo count(User::model()->findAll());
?>
名</a></li>
<li class="list"><a href="">美图: <?php
echo count(Album::model()->findAll());
?>
张</a></li>
<!-- <li class="list">余额:0.00元</li>
<li class="list">短信:无</li> -->
</ul>
<div class="clear"></div>
</div>
<ul class="tabui">
<li class="on"><a href="">服务器信息</a></li>
</ul>
<div class="table-ui">
<br>
示例12: array
<p><strong><?php
echo CHtml::link('最新专辑', array('album/newRelease'));
?>
</strong></p>
<div style="clear:both;width:100%">
<?php
foreach (Album::model()->published()->recently()->findAll() as $album) {
?>
<div style="float:left;text-align:center;">
<?php
echo CHtml::link(CHtml::image($album->picture, $album->name, array('width' => '90', 'height' => '90')), array('album/view', 'id' => $album->id));
?>
<p><?php
echo CHtml::link($album->name, array('album/view', 'id' => $album->id));
?>
</p>
<p><?php
echo CHtml::link($album->artist->name, array('artist/view', 'id' => $album->artist->id));
?>
</p>
</div>
<?php
}
?>
</div>
<hr />
示例13: newAlbum
private function newAlbum()
{
//check if this is an album or collection
//will also check if is a legall request, and if isn't, will throw an exception and stop
$isCollection = self::isCollection();
$models = $isCollection ? Collection::model()->findAll() : Album::model()->findAll();
//if we haven't set a pid manually, we will set first free pid
if (!$this->pid) {
$max = 0;
for ($i = 0; $i < 2; $i++) {
$testmodel = $i === 0 ? new Album() : new Collection();
$criteria = new CDbCriteria();
$criteria->select = 'max(pid) AS pid';
$row = $testmodel->model()->find($criteria);
$max = $max < $row['pid'] ? $row['pid'] : $max;
}
//if is first created albums or collections, we set $this->pid to 1;
$this->pid = $max ? (int) $max + 1 : 1;
$max;
}
$arrModelsNames = array();
foreach ($models as $m => $detail) {
$trs = unserialize($detail['translations']);
$name = $trs['name'][$this->lang->default];
$arrModelsNames[] = $name;
}
$modelNameTranslations = array();
$modelDescriptionTranslations = array();
$albumName = '';
foreach ($this->lang->all as $key => $language) {
$name = self::purifiedTtext($_POST['newAlbumName_' . $language]);
$name = $name ? $name : $this->tr('noName');
$description = self::purifiedTtext($_POST['newAlbumDescription_' . $language]);
$description = $description ? $description : $this->tr('noDescription');
if (count($arrModelsNames)) {
$p = explode(' ', $name);
$last = $p[count($p) - 1];
$name = is_numeric($last) ? self::firstFreeNameIndex($arrModelsNames, $name, $last) : ($name = self::firstFreeNameIndex($arrModelsNames, $name));
}
$modelNameTranslations[$language] = $name;
$modelDescriptionTranslations[$language] = $description;
$albumName .= ' ' . strtolower($name);
}
$translationsArr = array('name' => $modelNameTranslations, 'description' => $modelDescriptionTranslations);
$model = $isCollection ? new Collection() : new Album();
$model->pid = $this->pid;
$model->url = $this->getUrlRouteStructure();
$model->translations = serialize($translationsArr);
$model->author = Yii::app()->user->name;
$model->tags = self::tags($albumName);
if (!$model->save()) {
throw new Exception('fbgallery - newAlbum - ' . $this->tr('cantSave'));
} else {
if (!isset($_POST['isCollection'])) {
self::createFoldersStructure();
}
}
}
示例14: disableUserModule
/**
* delete all albums created by the given user.
* @param User $user
*/
public function disableUserModule(User $user)
{
$albums = Album::model()->findAll('created_by = :user', array(':user' => $user->id));
foreach ($albums as $album) {
$album->delete();
}
}
示例15: restEvents
public function restEvents()
{
/**
* req.get.resources.render
*
* Called when a GET request for when a list resources is to be rendered
*
* @param (Array) (data) this is an array of models representing the resources
* @param (String) (model_name) the name of the resources model
* @param (Array) (relations) the list of relations to include with the data
* @param (Int) (count) the count of records to return
*/
$this->onRest('req.get.resources.render', function ($data, $model_name, $relations, $count) {
//Handler for GET (list resources) request
$this->setHttpStatus($count > 0 ? 200 : 204);
$this->renderJSON(array('type' => 'rest', 'success' => $count > 0 ? true : false, 'message' => $count > 0 ? "Record(s) Found" : "No Record(s) Found", 'totalCount' => $count, 'modelName' => $model_name, 'relations' => $relations, 'data' => $data));
});
/**
* req.get.resource.render
*
* Called when a GET request for a single resource is to be rendered
* @param (Object) (data) this is the resources model
* @param (String) (model_name) the name of the resources model
* @param (Array) (relations) the list of relations to include with the data
* @param (Int) (count) the count of records to return (will be either 1 or 0)
*/
$this->onRest('req.get.resource.render', function ($data, $model_name, $relations, $count) {
//Handler for GET (single resource) request
$this->setHttpStatus($count > 0 ? 200 : 204);
$this->renderJSON(array('type' => 'rest', 'success' => $count > 0 ? true : false, 'message' => $count > 0 ? "Record Found" : "No Record Found", 'totalCount' => $count, 'modelName' => $model_name, 'relations' => $relations, 'data' => $data));
});
$this->onRest('req.post.album.', function ($data) {
//$data is the data sent in the POST
echo CJSON::encode(array('data' => $data));
});
/**
* model.delete
*
* Called whenever a model resource needs deleting
*
* @param (Object) (model) the model resource to be deleted
*/
$this->onRest('model.delete', function ($artist) {
/*print_r(Artist::PROTECTED_ARTISTS());
print_r($artist->id);
exit;*/
//DON'T LET USERS DELETE PROTECTED ARTISTS
if (in_array($artist->id, Artist::PROTECTED_ARTISTS())) {
throw new CHttpException(403, '<i>You cannot delete </i><h4>' . $artist->name . '</h4><br> It\'s demo data.Feel free to create,update and delete your own data.');
exit;
}
$albumsDeleted = true;
$tracksDeleted = true;
foreach ($artist->albums as $album) {
//delete tracks
$albumid = $album->id;
$tracks = Track::model()->findAllByAttributes(array('album_id' => $albumid));
foreach ($tracks as $track) {
$trackDeleted = $track->delete();
$tracksDeleted = $tracksDeleted && $trackDeleted;
}
//delete album
$albumdeleted = $album->delete();
$albumsDeleted = $albumsDeleted && $albumdeleted;
}
if (!$artist->delete()) {
throw new CHttpException(500, 'Could not delete model');
}
if (!$albumsDeleted) {
throw new CHttpException(500, 'Some artist\'s albums were not deleted');
}
if (!$tracksDeleted) {
throw new CHttpException(500, 'Some album tracks were not deleted');
}
if (!$this->unlinkArtistFromAlbums($artist->id)) {
throw new CHttpException(500, 'Artist was not unlinked from albums.');
}
return $artist;
});
//DON'T LET USERS UPDATE PROTECTED ARTISTS
$this->onRest('pre.filter.model.apply.put.data', function ($model, $data, $restricted_properties) {
if (in_array($model->id, Artist::PROTECTED_ARTISTS())) {
throw new CHttpException(403, '<i>You cannot modify </i><h4>' . $model->name . '</h4><br> It\'s demo data.Feel free to create,update and delete your own data.');
exit;
} else {
return array($model, $data, $restricted_properties);
}
//Array [Object, Array, Array]
});
/**
* model.subresources.save
*
* Called whenever a sub-resource is saved
*
* @param (Object) (model) the owner of the sub-resource
* @param (String) (subresource_name) the name of the subresource
* @param (Mixed/Int) (subresource_id) the primary key of the subresource
*
* @return (Object) the updated model representing the owner of the sub-resource
*/
//.........这里部分代码省略.........