本文整理汇总了PHP中cmsModel::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsModel::insert方法的具体用法?PHP cmsModel::insert怎么用?PHP cmsModel::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsModel
的用法示例。
在下文中一共展示了cmsModel::insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_perms
function add_perms($data, $type, $options = null)
{
$model = new cmsModel();
foreach ($data as $controller => $names) {
foreach ($names as $name) {
if (!$model->db->getRowsCount('perms_rules', "controller = '{$controller}' AND name = '{$name}'", 1)) {
$model->insert('perms_rules', array('controller' => $controller, 'name' => $name, 'type' => $type, 'options' => $options));
}
}
}
}
示例2: savePermissions
/**
* Сохраняет значения правил для субъекта
* @param string $subject Субъект действия правила
* @param array $perms Правила и их значения
*/
static function savePermissions($subject, $perms)
{
$model = new cmsModel();
foreach ($perms as $rule_id => $values) {
if (is_null($values)) {
$model->filterEqual('subject', $subject)->filterEqual('rule_id', $rule_id)->deleteFiltered('perms_users');
continue;
}
foreach ($values as $group_id => $value) {
$model->filterEqual('subject', $subject)->filterEqual('rule_id', $rule_id)->filterEqual('group_id', $group_id)->lockFilters();
if (!$value) {
$model->deleteFiltered('perms_users');
$model->unlockFilters();
$model->resetFilters();
continue;
}
$is_exists = $model->getFieldFiltered('perms_users', 'value');
$model->unlockFilters();
if ($is_exists) {
$model->updateFiltered('perms_users', array('rule_id' => $rule_id, 'group_id' => $group_id, 'subject' => $subject, 'value' => $value));
} else {
$model->insert('perms_users', array('rule_id' => $rule_id, 'group_id' => $group_id, 'subject' => $subject, 'value' => $value));
}
}
$model->resetFilters();
}
}
示例3: widgetInstall
private function widgetInstall($manifest)
{
$model = new cmsModel();
$model->insert('widgets', array('title' => $manifest['info']['title'], 'name' => $manifest['package']['name'], 'controller' => $manifest['package']['controller'], 'author' => isset($manifest['author']['name']) ? $manifest['author']['name'] : LANG_CP_PACKAGE_NONAME, 'url' => isset($manifest['author']['url']) ? $manifest['author']['url'] : null, 'version' => $manifest['version']['major'] . '.' . $manifest['version']['minor'] . '.' . $manifest['version']['build']));
return 'widgets';
}