本文整理匯總了PHP中sql::sortTable方法的典型用法代碼示例。如果您正苦於以下問題:PHP sql::sortTable方法的具體用法?PHP sql::sortTable怎麽用?PHP sql::sortTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sql
的用法示例。
在下文中一共展示了sql::sortTable方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
echo message::success(lang::get('file_deleted'));
}
}
if (in_array($action, ['save-add', 'save-edit']) && dyn::get('user')->hasPerm('media[category][edit]')) {
$sql = sql::factory();
$sql->setTable('media_cat');
$sql->setWhere('id=' . $id);
$sql->getPosts(['name' => 'string', 'sort' => 'int', 'pid' => 'int']);
if ($action == 'save-edit') {
$sql->update();
} else {
$sql->save();
}
$sort = type::post('sort', 'int');
$parent_id = type::post('pid', 'int');
sql::sortTable('media_cat', $sort, '`pid` = ' . $parent_id . ' AND id != ' . $id);
}
$table = table::factory(['class' => ['js-sort']]);
$colFirstWidth = $action == 'edit' || $action == 'add' ? 50 : 25;
$table->addCollsLayout($colFirstWidth . ',*, 110');
$table->addRow()->addCell()->addCell(lang::get('category'))->addCell(lang::get('action'));
$table->addSection('tbody');
$table->setSql('SELECT * FROM ' . sql::table('media_cat') . ' WHERE pid = ' . $pid . ' ORDER BY sort ASC');
if (in_array($action, ['edit', 'add']) && dyn::get('user')->hasPerm('media[category][edit]')) {
echo '<form method="post" action="index.php">';
$inputHidden = formInput::factory('action', 'save-' . $action);
$inputHidden->addAttribute('type', 'hidden');
echo $inputHidden->get();
$inputHidden = formInput::factory('page', 'media');
$inputHidden->addAttribute('type', 'hidden');
echo $inputHidden->get();
示例2: saveSortUp
protected static function saveSortUp($id, $sort)
{
sql::sortTable('structure_area', $sort, '`structure_id` = ' . $id);
}
示例3:
$id = $sql->get('id');
$delete = sql::factory();
$delete->setTable('structure');
$delete->setWhere('id=' . $id);
$delete->delete();
} else {
$id = false;
}
}
$sql = sql::factory();
$sql->query('SELECT `sort`, `parent_id` FROM ' . sql::table('structure') . ' WHERE id=' . $orginal_id)->result();
$delete = sql::factory();
$delete->setTable('structure');
$delete->setWhere('id=' . $orginal_id);
$delete->delete();
sql::sortTable('structure', 0, '`parent_id` = ' . $sql->get('parent_id'));
echo message::success(lang::get('structure_delete'));
$action = '';
}
if ($action == 'online' && dyn::get('user')->hasPerm('page[edit]')) {
$sql = sql::factory();
$sql->query('SELECT online FROM ' . sql::table('structure') . ' WHERE id=' . $id)->result();
$online = $sql->get('online') ? 0 : 1;
$sql->setTable('structure');
$sql->setWhere('id=' . $id);
$sql->addPost('online', $online);
$sql->update();
echo message::success(lang::get('save_status'));
$action = '';
}
if ($action == '') {
示例4: saveSortUp
protected static function saveSortUp($id, $sort, $block)
{
$block = $block ? 1 : 0;
sql::sortTable('structure_area', $sort, '`structure_id` = ' . $id . ' AND `block` = ' . $block);
}