本文整理汇总了PHP中CActiveDataProvider::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveDataProvider::getData方法的具体用法?PHP CActiveDataProvider::getData怎么用?PHP CActiveDataProvider::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveDataProvider
的用法示例。
在下文中一共展示了CActiveDataProvider::getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDataArray
protected function createDataArray()
{
\Yii::beginProfile('createDataArray');
$data = [];
Yii::beginProfile('getData');
if (!$this->config['serverSide']) {
$paginator = $this->dataProvider->getPagination();
if ($this->dataProvider instanceof \CActiveDataProvider) {
$this->dataProvider->criteria->order = '';
}
$this->dataProvider->setPagination(false);
$source = $this->dataProvider->getData(true);
$this->dataProvider->setPagination($paginator);
} else {
$source = $this->dataProvider->getData();
}
Yii::endProfile('getData');
Yii::beginProfile('renderCells');
// Get column name map.
$names = array_map([$this, 'getColumnName'], $this->columns);
foreach ($source as $i => $r) {
$row = [];
foreach ($this->columns as $j => $column) {
$name = $names[$j];
$row[$name] = $column->getDataCellContent($i);
}
$metaRow = [];
if ($this->addMetaData !== false) {
Yii::beginProfile('addMetaData');
if (is_callable([$r, 'getKeyString'])) {
$metaRow['data-key'] = call_user_func([$r, 'getKeyString']);
}
if (is_array($this->addMetaData)) {
foreach ($this->addMetaData as $field) {
$metaRow["data-{$field}"] = \CHtml::value($r, $field);
}
}
Yii::endProfile('addMetaData');
}
if (isset($this->rowCssClassExpression)) {
$metaRow['class'] = $this->evaluateExpression($this->rowCssClassExpression, array('row' => $i, 'data' => $r));
}
$row['metaData'] = $metaRow;
$data[] = $row;
}
\Yii::endProfile('renderCells');
\Yii::endProfile('createDataArray');
return $data;
}
示例2: actionFeed
public function actionFeed()
{
Yii::import('aiajaya.extensions.efeed.*');
// RSS 2.0 is the default type
$feed = new EFeed();
$feed->title = 'Gästebuch von ' . Yii::app()->name;
$feed->description = 'Das Gästebuch vom ' . Yii::app()->name;
$feed->addChannelTag('language', 'de-de');
$feed->addChannelTag('pubDate', date(DATE_RSS, time()));
$feed->addChannelTag('link', $this->createAbsoluteUrl('/page/guestbook/list'));
// * self reference
$feed->addChannelTag('atom:link', $this->createAbsoluteUrl('/page/guestbook/feed'));
$criteria = new CDbCriteria(array('order' => '`createDate` DESC'));
$dataProvider = new CActiveDataProvider('Comment', array('pagination' => array('pageSize' => 0), 'criteria' => $criteria));
foreach ($dataProvider->getData() as $comment) {
$item = $feed->createNewItem();
$item->title = $comment->getBaseModel()->commentName;
$item->link = $this->createAbsoluteUrl('/page/page/get', array('key' => $comment->getBaseModel()->key));
$item->date = $comment->createDate;
$item->description = $comment->message;
$item->addTag('author', $comment->name);
//$item->addTag('guid', 'http://www.ramirezcobos.com/',array('isPermaLink'=>'true'));
$feed->addItem($item);
}
$feed->generateFeed();
Yii::app()->end();
}
示例3: actionGetBidHistory
public function actionGetBidHistory($id)
{
$dataAdapter = new CActiveDataProvider('Bidding', array('criteria' => array('condition' => 'fk_user = 1', 'limit' => '10', 'order' => 'id_bidding DESC')));
$this->apiResponse['data'] = $dataAdapter->getData();
$this->apiResponse['success'] = true;
$this->sendResponse();
}
示例4: actionView
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$user = User::model()->findByPk($id);
$dataProvider = new CActiveDataProvider('Actions', array('criteria' => array('order' => 'complete DESC', 'condition' => 'assignedTo=\'' . $user->username . '\'')));
$actionHistory = $dataProvider->getData();
$this->render('view', array('model' => $this->loadModel($id), 'actionHistory' => $actionHistory));
}
示例5: actionIndex
public function actionIndex()
{
if (Yii::app()->user->isGuest) {
Yii::app()->user->loginRequired();
}
$settings = array();
// Get user settings.
$criteria = new CDbCriteria(array('condition' => 'uid=' . Yii::app()->user->id));
$dataProvider = new CActiveDataProvider('DashboardPortlet', array('criteria' => $criteria));
$data = $dataProvider->getData();
if (isset($data[0])) {
$userSettings = unserialize($data[0]->settings);
foreach ($userSettings as $class => $properties) {
$settings[$properties['column']][$properties['weight']] = array('class' => $class, 'visible' => $properties['visible'], 'weight' => $properties['weight']);
}
foreach ($settings as $key => $value) {
// Sort all portlets in every column by weight.
ksort($settings[$key]);
}
}
// Use the default portlets settings if user did not set any portlet before.
if (empty($settings)) {
$deaultSettings = $this->getModule()->portlets;
foreach ($deaultSettings as $class => $properties) {
$column = isset($properties['column']) ? $properties['column'] : 0;
$settings[$column][$properties['weight']] = array('class' => $class, 'visible' => isset($properties['visible']) ? $properties['visible'] : true, 'weight' => $properties['weight']);
}
}
$this->render('index', array('portlets' => $settings));
}
示例6: getListItems
/**
* getListItems - Phương thức dùng để lấy dữ liệu
*/
public function getListItems($category_id = null)
{
Yii::import('application.modules.products.models.ProductItem');
$model = new ProductItem('search');
$model->unsetAttributes();
$criteria = new CDbCriteria();
$criteria->order = 'created DESC';
if ($category_id) {
Yii::import('application.modules.products.models.ProductCategory');
$categories = ProductCategory::model()->findByPk($category_id);
if (!$categories) {
return null;
}
$this->__category = $categories;
$descendants = $categories->descendants()->findAll('is_active = 1');
$arrCat = array($category_id);
foreach ($descendants as $cat) {
$arrCat[] = $cat->id;
}
$criteria->with = array('categoryitem');
$criteria->together = true;
foreach ($arrCat as $cat) {
$criteria->compare('categoryitem.category_id', $cat, false, 'OR');
}
}
$criteria->compare('status', 1);
$search = new CActiveDataProvider($model, array('criteria' => $criteria, 'pagination' => array('pageSize' => Yii::app()->getModule('products')->entriesShow)));
$data = $search->getData();
$this->__pagination = $search->pagination;
return $data;
}
示例7: actionDashboard
/**
* Manages all models.
*/
public function actionDashboard()
{
/* Wall Post */
$model = new OmmuWalls();
/* Get Walll */
$criteria = new CDbCriteria();
$criteria->condition = 'publish = :publish';
$criteria->params = array(':publish' => 1);
$criteria->order = 'creation_date DESC';
$dataProvider = new CActiveDataProvider('OmmuWalls', array('criteria' => $criteria, 'pagination' => array('pageSize' => 5)));
$data = '';
$wall = $dataProvider->getData();
if (!empty($wall)) {
foreach ($wall as $key => $item) {
$data .= Utility::otherDecode($this->renderPartial('/wall/_view', array('data' => $item), true, false));
}
}
$pager = OFunction::getDataProviderPager($dataProvider);
if ($pager[nextPage] != '0') {
$summaryPager = 'Displaying 1-' . $pager[currentPage] * $pager[pageSize] . ' of ' . $pager[itemCount] . ' results.';
} else {
$summaryPager = 'Displaying 1-' . $pager[itemCount] . ' of ' . $pager[itemCount] . ' results.';
}
$nextPager = $pager['nextPage'] != 0 ? Yii::app()->createUrl('wall/get', array($pager['pageVar'] => $pager['nextPage'])) : 0;
$this->pageTitle = Yii::t('phrase', 'Welcome') . ', ' . Yii::app()->user->displayname . '!';
$this->pageDescription = Yii::t('phrase', 'Welcome to your social network control panel. Here you can manage and modify every aspect of your social network. Directly below, you will find a quick snapshot of your social network including some useful statistics.');
$this->pageMeta = '';
$this->render('application.webs.admin.admin_dashboard', array('model' => $model, 'data' => $data, 'pager' => $pager, 'summaryPager' => $summaryPager, 'nextPager' => $nextPager));
}
示例8: actionExcel
public function actionExcel($id)
{
$po = $this->loadModel($id);
$poItemCriteria = new CDbCriteria();
$poItemCriteria->with = array('material');
$poItemCriteria->compare('po_number', $id);
$poItemDataProvider = new CActiveDataProvider('PoItems', array('criteria' => $poItemCriteria, 'pagination' => false));
Yii::import('ext.phpexcel.XPHPExcel');
$objPHPExcel = XPHPExcel::createPHPExcel();
$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load(Yii::app()->basePath . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . "templates" . DIRECTORY_SEPARATOR . "PO_Template.xls");
$objPHPExcel->getProperties()->setCreator(Yii::app()->user->name)->setLastModifiedBy(Yii::app()->user->name)->setTitle("PO Order-" . $id);
//->setSubject("Office 2007 XLSX Test Document")
//->setDescription("Sales Order#")
//->setKeywords("office 2007 openxml php")
//->setCategory("Test result file");
// Add the data
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('C2', $po->po_number)->setCellValue('C3', Yii::app()->dateFormatter->formatDateTime($po->maturity_date, "short", null))->setCellValue('C4', Yii::app()->dateFormatter->formatDateTime($po->created, "short", null))->setCellValue('C5', Yii::app()->dateFormatter->formatDateTime($po->updated, "short", null))->setCellValue('E2', $po->comp->name)->setCellValue('E3', $po->contact)->setCellValue('E4', $po->contact_telephone)->setCellValue('C6', $po->paymentTerm->description)->setCellValue('C7', $po->is_open ? "Open" : "Closed")->setCellValue('A8', "Comments:\r" . $po->comments);
$row = 13;
//$i = 1;
// Write the sale items now
$items = $poItemDataProvider->getData();
foreach ($items as $item) {
$objPHPExcel->setActiveSheetIndex(0)->setCellValue("B" . $row, $item->material->cat->description . "-" . $item->material->description)->setCellValue("D" . $row, $item->qty)->setCellValue("E" . $row, $item->qty_units)->setCellValue("F" . $row, $item->unit_price)->setCellValue("G" . $row, $item->price_units)->setCellValue("H" . $row, $item->qty_recieved)->setCellValue("I" . $row, $item->qty_diff);
//$i++;
$row++;
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
// Redirect output to a client’s web browser
//header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename=' . '"PurchaseOrder-' . $id . '.xls"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');
}
示例9: actionIndex
public function actionIndex()
{
$with = array('active_keywords');
$whereType = "and t.type='" . Globals::TYPE_REGISTRATION . "' and active_keywords.type='" . Globals::TYPE_ACTIVE . "'";
$this->layout = '//layouts/memberList';
$dataProvider = new CActiveDataProvider('ActiveModel', array('criteria' => array('order' => 't.id DESC', 'with' => $with, 'condition' => "t.wechatId = {$this->wechatInfo->id} {$whereType}", 'together' => true), 'pagination' => array('pageSize' => Page::SIZE, 'pageVar' => 'page')));
$this->render('index', array('data' => $dataProvider->getData(), 'pages' => $dataProvider->getPagination(), 'wechatInfo' => $this->wechatInfo));
}
示例10: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
//$this->redirect('/card/index');
//$dataProvider=new CActiveDataProvider('Product');
$dataProvider = new CActiveDataProvider('Product', array('pagination' => array('pageSize' => 100)));
$products = $dataProvider->getData();
$model = new Order();
$this->render('index', compact('model', 'products'));
}
示例11: page
/**
* 手机客户端的分页,防止分页重复,与网页显示无关
* @param CActiveDataProvider $dataProvider
*
*/
public function page(CActiveDataProvider &$dataProvider, $more = true)
{
$total = $dataProvider->getTotalItemCount();
$pageSzie = $dataProvider->getPagination()->getPageSize();
$dataProvider->getPagination()->pageVar = 'page';
$pageCount = ceil($total / $pageSzie);
if ($dataProvider->getTotalItemCount() == 0) {
$this->send(ERROR_EMPTY, 'data empty', $more);
} else {
if (isset($_GET['page'])) {
if ($pageCount >= $_GET['page']) {
$this->send(0, $dataProvider->getData(), $more, array('page' => $pageCount));
}
} else {
$this->send(ERROR_NONE, $dataProvider->getData(), $more, array('page' => $pageCount));
}
}
}
示例12: actionIndex
/**
* @param bool $ajax
*/
public function actionIndex($ajax = false)
{
if ($ajax) {
$dataProvider = new CActiveDataProvider('SurveillanceSections', ['criteria' => ['condition' => "tool='surveillance'", 'select' => 'sectionId, sectionName, description']]);
echo CJSON::encode(['aaData' => $dataProvider->getData()]);
return;
}
$this->render('index');
}
示例13: getRoomTypeList
public function getRoomTypeList()
{
$dataProvider = new CActiveDataProvider('RoomType');
$roomTypes = $dataProvider->getData();
$roomTypesDropdown = array();
foreach ($roomTypes as $roomType) {
$roomTypesDropdown[$roomType->id] = $roomType->description;
}
}
示例14: actionIndex
public function actionIndex()
{
$roleDataProvider = new CActiveDataProvider('AuthItem', array('criteria' => array('condition' => 'type=2')));
echo '<pre>';
var_dump($roleDataProvider->getData());
echo '</pre>';
exit;
$this->render('index');
}
示例15: run
public function run($args)
{
ignore_user_abort(true);
set_time_limit(0);
$dataProvider = new CActiveDataProvider('Category', array('criteria' => array('order' => 'id ASC'), 'pagination' => false));
foreach ($dataProvider->getData() as $category) {
echo $category->name;
}
}