本文整理汇总了PHP中Widget::tableName方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::tableName方法的具体用法?PHP Widget::tableName怎么用?PHP Widget::tableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::tableName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSectionsArray
public function getSectionsArray()
{
$attr = Widget::getI18nFieldName('title', 'Widget');
$sql = 'SELECT ns.`id`, u.`' . $attr . '` FROM `' . Widget::tableName() . '` as u
INNER JOIN `' . ModelBlog::tableName() . '` as ns
ON u.id = ns.widget_id
WHERE u.`class` = "WidgetBlog" ORDER BY u.`' . $attr . '`';
$result = Yii::app()->db->createCommand($sql)->queryAll();
$ret = array();
foreach ($result as $row) {
$ret[$row['id']] = $row[$attr];
}
return $ret;
}
示例2: actionInstall
/**
* Страница инсталляции/деинсталляции блоков
*/
public function actionInstall()
{
$allUnits = ContentUnit::getAvailableUnits();
$errors = array();
if (isset($_POST['Units'])) {
$units = array_keys($_POST['Units']);
ContentUnit::install($units);
$uninstall = array_diff(array_keys($allUnits), $units);
foreach ($uninstall as $i => $className) {
$sql = 'SELECT count(*) FROM `' . Widget::tableName() . '` WHERE `class` = :class';
$command = Yii::app()->db->createCommand($sql);
$command->bindValue(':class', $className, PDO::PARAM_STR);
$exists = $command->queryScalar();
if ($exists) {
unset($uninstall[$i]);
$errors[] = Yii::t('cms', 'Can\\`t unistall "{name}"', array('{name}' => $allUnits[$className]['name']));
}
}
ContentUnit::uninstall($uninstall);
$allUnits = ContentUnit::getAvailableUnits();
}
$this->render('install', array('units' => $allUnits, 'errors' => $errors));
}
示例3: afterDelete
public function afterDelete()
{
PageWidget::model()->deleteAll('page_id = :page_id', array(':page_id' => $this->id));
// Удаляем все блоки, которые больше нигде не размещены
$sql = 'SELECT `widget`.`id`, `widget`.`class` FROM `' . Widget::tableName() . '` as `widget`
LEFT JOIN `' . PageWidget::tableName() . '` as `pagewidget` ON (`widget`.`id` = `pagewidget`.`widget_id`)
$pus = Yii::app()->db->createCommand($sql)->queryAll();
WHERE `pagewidget`.`id` IS NULL';
$ids = array();
if ($pus && is_array($pus)) {
foreach ($pus as $pu) {
$ids[] = intval($pu['id']);
$widgetClass = $pu['class'];
$modelClass = call_user_func(array($widgetClass, 'modelClassName'));
call_user_func(array($modelClass, 'model'))->deleteAll('widget_id = ' . intval($pu['id']));
}
$sql = 'DELETE FROM `' . Widget::tableName() . '` WHERE `id` IN (' . implode(',', $ids) . ')';
Yii::app()->db->createCommand($sql)->execute();
}
return parent::afterDelete();
}