本文整理汇总了PHP中Storage::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::model方法的具体用法?PHP Storage::model怎么用?PHP Storage::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Storage
的用法示例。
在下文中一共展示了Storage::model方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPictureInfo
/**
* Gets the profile picture for a specifc user.
* @param string $userId The Id of the user to get profile picture. If this is empty, the current user's avatar will be returned.
* @param string $type The type of picture to return (original, thumb.profile, thumb.feed, thumb.icon)
* @return array The picture info (path, alt, title, width, height)
*/
public static function getPictureInfo($userId = '', $type = 'orginal')
{
if (empty($userId)) {
$userId = Yii::app()->user->getId();
if (empty($userId)) {
return null;
}
}
$pictureId = Profile::model()->getFieldInfo($userId, User::PREFIX, 'picture');
if ($pictureId === null) {
return self::getDefaultPicture($userId, $type);
}
$pictureInfo = Storage::model()->get($pictureId);
// Alt and title
$info = array('alt' => $pictureInfo['title'] . ' - ' . $pictureInfo['description'], 'title' => $pictureInfo['title']);
// Path
if ($type === 'original') {
$info['path'] = $pictureInfo['storage_path'];
} else {
if (isset($pictureInfo[$type])) {
$info['path'] = $pictureInfo[$type];
} else {
$info['path'] = Yii::app()->getBaseUrl(true) . '/files/images/error.jpg';
$info['width'] = $info['height'] = 160;
}
}
// Size
if (!isset($info['width'])) {
$imageInfo = getimagesize($info['path']);
$info['width'] = $imageInfo[0];
$info['height'] = $imageInfo[1];
}
return $info;
}
示例2: actionTodayStorage
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionTodayStorage()
{
$dates = date('Y:m:d');
$depId = $_POST['depId'];
$Products = array();
/*$model = DepBalance::model()->with('products')->findAll('t.department_id = :depId AND t.type = :type',array(':depId'=>$depId,'type'=>1));
foreach ($model as $val) {
$products[$val->prod_id] = $val->getRelated('products')->name;
}*/
//$model = new Products();
//$products = $model->getProdName($depId);
$storageModel = Storage::model()->findAll();
$balanceModel = Balance::model()->with('products')->findAll('b_date = :b_date', array(':b_date' => $dates));
if (!empty($balanceModel)) {
foreach ($balanceModel as $val) {
$products[$val->prod_id] = $val->getRelated('products')->name;
$Products[$val->prod_id] = $Products[$val->prod_id] + $val->startCount;
}
} else {
foreach ($storageModel as $val) {
$Products[$val->prod_id] = $Products[$val->prod_id] + $val->curCount;
}
}
$realizedProd = Faktura::model()->with('realize.products')->findAll('date(realize_date) = :realize_date', array('realize_date' => $dates));
foreach ($realizedProd as $value) {
foreach ($value->getRelated('realize') as $val) {
$Products[$val->prod_id] = $Products[$val->prod_id] + $val->count;
}
}
$realizeStorageProd = DepFaktura::model()->with('realizedProd')->findAll('date(real_date) = :real_date AND fromDepId = :fromDepId', array(':real_date' => $dates, ':fromDepId' => 0));
foreach ($realizeStorageProd as $value) {
foreach ($value->getRelated('realizedProd') as $val) {
$Products[$val->prod_id] = $Products[$val->prod_id] - $val->count;
}
}
$expBalance = Yii::app()->db->createCommand()->select('ord.just_id,ord.count')->from('expense ex')->join('orders ord', 'ord.expense_id = ex.expense_id')->where('date(ex.order_date) = :dates AND ex.kind = :kind ', array(':dates' => $dates, ':kind' => 1))->queryAll();
foreach ($expBalance as $val) {
$Products[$val['just_id']] = $Products[$val['just_id']] - $val['count'];
}
$this->renderPartial('todayStorage', array('Products' => $Products, 'products' => $products, 'depId' => $depId));
}
示例3: createOrNone
/**
* @return bool
*/
public function createOrNone()
{
$this->verifyTable();
if (!Storage::model()->findByAttributes(array('key' => $this->hash()))) {
$storage = new Storage();
$storage->key = $this->hash();
$storage->value = json_encode($this->generateBrief());
return $storage->save();
}
return false;
}
示例4: actionCalendarEvents
public function actionCalendarEvents()
{
$items = array();
$model = Storage::model()->findAll();
foreach ($model as $value) {
$items[] = array('id' => $value->storage_id, 'url' => '#');
}
echo CJSON::encode($items);
Yii::app()->end();
}