本文整理汇总了PHP中Photo::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::model方法的具体用法?PHP Photo::model怎么用?PHP Photo::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Photo
的用法示例。
在下文中一共展示了Photo::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionPhoto
public function actionPhoto()
{
$criteria = new CDbCriteria();
$criteria->limit = 25;
$model = Photo::model()->is_publish()->findAll($criteria);
$this->setRss($model, 'photo', 'Photo', 'Rss Feed Photo', $this->createUrl('photo'));
}
示例2: actionList
public function actionList()
{
$request = Yii::app()->getRequest();
$page = $request->getParam("page");
if (!$page) {
$page = 1;
}
$pagenum = $request->getParam("pagenum");
if (!$pagenum) {
$pagenum = 12;
}
$winner = new Winner();
$criteria = new CDbCriteria();
$criteria->select = '*';
$criteria->limit = $pagenum;
$criteria->offset = ($page - 1) * $pagenum;
$criteria->order = 'month DESC';
$winners = $winner->findAll($criteria);
$res = array();
foreach ($winners as $winner) {
$res[] = $winner->attributes;
}
$topPhoto = Photo::model()->findByAttributes(array('weibo_id' => $winners[0]->mid));
if ($topPhoto) {
$res[0]['detail'] = $topPhoto->attributes;
}
$this->responseJSON($res, "success");
}
示例3: actionIndex
public function actionIndex()
{
echo "================================================================================\n\r";
echo "ATMOSPHERA console command: Batch resizing of uploaded photos\n\r";
echo "================================================================================\n\r";
$fileform = new PhotoFileForm();
//get instance of model
$fileform->setImageSize();
//set sizes from params-local
$path = UrlHelper::getImageDir();
//get dir for upload
$criteia = new CDbCriteria();
$countTotal = Photo::model()->count($criteia);
echo "total count of photo: " . $countTotal . "\n\r";
echo "start process... please wait\n\r";
$offset = 0;
//DebugBreak();
$step = floor($countTotal / 10);
$criteia->limit = $step;
$criteia->offset = $offset;
$countTotal = 0;
while (($count = count($aPhotos = Photo::model()->findAll($criteia))) > 0) {
foreach ($aPhotos as $oPhoto) {
$fileform->createImages($path, $oPhoto->filename, $oPhoto->thumb_filename);
}
$offset += $step;
$criteia = new CDbCriteria();
$criteia->limit = $step;
$criteia->offset = $offset;
$countTotal += $count;
echo ".";
}
echo "\n\r";
echo "total count of processed files: " . $countTotal . "\n\r";
}
示例4: loadPost
private function loadPost($id, $slug)
{
$model = Photo::model()->is_publish()->findByAttributes(array('ID' => (int) $id, 'post_link' => $slug));
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例5: run
public function run()
{
$criteria = new CdbCriteria();
$criteria->limit = $this->data('limit');
$criteria->offset = $this->data('offset');
$model = Photo::model()->is_publish()->findAll($criteria);
$this->layout($model);
}
示例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.
* @param integer $id the ID of the model to be loaded
* @return Photo the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Photo::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例7: actionGetImages
public function actionGetImages()
{
set_time_limit(0) or die('1');
$photos = Photo::model()->findAll(array('limit' => 3500, 'offset' => 10000));
foreach ($photos as $photo) {
$this->downloadPhoto($photo->path);
}
}
示例8: getPhotoByAlbum
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function getPhotoByAlbum($id)
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria();
$criteria->condition = "album_id = '{$id}'";
$criteria->order = "id asc";
$model = Photo::model()->findAll($criteria);
return $model;
}
示例9: actionCustomer
public function actionCustomer()
{
$model = new Order();
$errorMessage = null;
if (isset($_GET['order_id']) && Order::model()->isValidateOrderId($_GET['order_id'])) {
$model = $this->loadExistOrder($_GET['order_id']);
$model->order_info = OrderState::model()->getStateZnByStateId($model->order_state_id) . $model->remark;
$model->product_name = Product::model()->getProductNameByProductId($model->product_id);
$model->order_photos = Photo::model()->findAllByAttributes(array('product_id' => $model->product_id));
} else {
$model->unsetAttributes();
$errorMessage = Yii::t('order', 'Order is not exist!');
}
$this->layout = false;
$this->render('_customer', array('model' => $model, 'message' => $errorMessage));
}
示例10: actionPhotos
public function actionPhotos()
{
if (!empty($_POST)) {
if (isset($_POST['deletephotos'])) {
$anketa = Anketa::model()->findByPk(Yii::app()->user->id);
if (!$anketa) {
throw new CException('Error user');
}
if (isset($_POST['delete']) && is_array($_POST['delete'])) {
foreach ($_POST['delete'] as $k => $v) {
if ($k == $anketa->mainphoto) {
$anketa->mainphoto = null;
$anketa->saveAttributes(array('mainphoto'));
}
if ($model = Photo::model()->findByPk(array('id_user' => Yii::app()->user->id, 'id_photo' => $k))) {
$model->delete();
}
}
Yii::app()->user->setFlash('profile', 'Информация обновлена');
} else {
Yii::app()->user->setFlash('profile', 'Не выбраны фото для удаления');
}
$this->refresh();
} else {
if (isset($_POST['mainphoto'])) {
$id = array_keys($_POST['mainphoto']);
$id = $id[0];
$model = Anketa::model()->findByPk(Yii::app()->user->id);
if (!$model) {
throw new CException('Error user');
}
$photo = Photo::model()->findByPk(array('id_photo' => $id, 'id_user' => $model->id));
if (!$photo) {
throw new CException('Error photo');
}
$model->mainphoto = $id;
$model->saveAttributes(array('mainphoto'));
Yii::app()->user->setFlash('profile', 'Основная фотография изменена');
$this->refresh();
}
}
}
$models = Photo::model()->findAllByAttributes(array('id_user' => Yii::app()->user->id));
$user = Anketa::model()->findByPk(Yii::app()->user->id);
$this->render('photos', compact('models', 'user'));
}
示例11: actionInside
public function actionInside()
{
if (isset($_GET['id'])) {
$model = News::model()->findByPk($_GET['id']);
$model_photo = Photo::model()->getPhotoByAlbum($_GET['id']);
//print_r($model_photo);
$this->render('detail', array('model' => $model, 'model_photo' => $model_photo));
} else {
$news_criteria = new CDbCriteria();
$news_criteria->condition = "status = 1 AND news_type_id = 5";
$news_criteria->order = "create_date desc,news_id desc";
$news_total = News::model()->count($news_criteria);
$pages = new CPagination($news_total);
$pages->setPageSize(10);
$pages->applyLimit($news_criteria);
$news = News::model()->findAll($news_criteria);
$this->render('news', array('news' => $news, 'pages' => $pages));
}
}
示例12: actionDelete
public function actionDelete($id)
{
$service = Service::model()->findAll('contractor_id=' . $id);
if ($service) {
foreach ($service as $serv) {
WrapServTransport::Del($serv->id);
ServCulture::model()->deleteAllByAttributes(array('service_id' => $serv->id));
$food = ServFood::model()->findAll('service_id=' . $serv->id);
if ($food) {
foreach ($food as $mFood) {
LinkFoodServ::model()->deleteAllByAttributes(array('serv_food_id' => $mFood->id));
}
}
ServFood::model()->deleteAllByAttributes(array('service_id' => $serv->id));
ServIntensiv::model()->deleteAllByAttributes(array('service_id' => $serv->id));
ServOther::model()->deleteAllByAttributes(array('service_id' => $serv->id));
$personal = ServPersonal::model()->findAll('service_id=' . $serv->id);
if ($personal) {
foreach ($personal as $mPers) {
LinkPersonalLanguage::model()->deleteAllByAttributes(array('serv_personal_id' => $mPers->id));
}
}
ServPersonal::model()->deleteAllByAttributes(array('service_id' => $serv->id));
ServPlatform::model()->deleteAllByAttributes(array('service_id' => $serv->id));
ServProgram::model()->deleteAllByAttributes(array('service_id' => $serv->id));
ServTicket::model()->deleteAllByAttributes(array('service_id' => $serv->id));
$live = ServLive::model()->findAll('service_id=' . $serv->id);
if ($live) {
foreach ($live as $mLive) {
ServLiveRoom::model()->deleteAllByAttributes(array('serv_live_id' => $mLive->id));
}
}
ServLive::model()->deleteAllByAttributes(array('service_id' => $serv->id));
Photo::model()->deleteAllByAttributes(array('service_id' => $serv->id));
}
}
Service::model()->deleteAllByAttributes(array('contractor_id' => $id));
Comment::model()->deleteAllByAttributes(array('contractor_id' => $id));
LinkCityContractor::model()->deleteAllByAttributes(array('contractor_id' => $id));
Contractor::model()->deleteByPk($id);
echo "ok";
}
示例13: getImageSrc
public function getImageSrc($imageSize = Photo::SIZE_MEDIUM)
{
if (($profile = $this->profile) !== null) {
if (($photo = Photo::model()->findByPk($profile->photo_id)) !== null) {
return ($src = $photo->getSrcAsSize($imageSize)) !== null ? $src : self::getDefaultImgSrc($imageSize);
}
}
return self::getDefaultImgSrc($imageSize);
}
示例14: tearDown
function tearDown()
{
if ($this->photo_id) {
$photo = Photo::model()->findByPk($this->photo_id)->delete();
}
}
示例15: actionGetUserAllPhoto
/**
* 获取用户得到的所有照片
*
*/
public function actionGetUserAllPhoto()
{
// 参数检查
if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['token']) || !isset($_REQUEST['type'])) {
$this->_return('MSG_ERR_LESS_PARAM');
}
$user_id = trim(Yii::app()->request->getParam('user_id'));
$token = trim(Yii::app()->request->getParam('token'));
$type = trim(Yii::app()->request->getParam('type'));
$timestamp = trim(Yii::app()->request->getParam('timestamp'));
if (!is_numeric($user_id)) {
$this->_return('MSG_ERR_FAIL_PARAM');
}
//验证token
if (!Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) {
$this->_return('MSG_ERR_TOKEN');
}
$timestamp = strtotime($timestamp);
//用户不存在 返回错误
if ($user_id < 1) {
$this->_return('MSG_ERR_NO_USER');
}
$image = Photo::model()->getUserAllPhoto($user_id, $type, $timestamp);
$this->_return('MSG_SUCCESS', $image);
}