本文整理汇总了PHP中sql::setWhere方法的典型用法代码示例。如果您正苦于以下问题:PHP sql::setWhere方法的具体用法?PHP sql::setWhere怎么用?PHP sql::setWhere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sql
的用法示例。
在下文中一共展示了sql::setWhere方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: control
protected function control($type)
{
$id = $this->id;
$SSH = rp::get('SSH');
$host = $SSH['ip'];
$user = $SSH['user'];
$pass = $SSH['password'];
unset($SSH);
$ssh = new ssh($host, $user, $pass);
$sql = new sql();
$sql->setTable('server');
$sql->setWhere('id=' . $id);
#$ssh->read('[prompt]');
switch ($type) {
case 'install':
$ssh->exec("cd {$id}; ./control.sh auto-install > /dev/null &");
$sql->addPost('status', 0);
break;
case 'start':
$ssh->exec("cd {$id}; ./control.sh start >> /dev/null 2>&1 & /n");
$sql->addPost('status', 1);
break;
case 'stop':
$ssh->exec("cd {$id}; ./control.sh stop >> /dev/null 2>&1 & /n");
$sql->addPost('status', 0);
break;
case 'restart':
$ssh->exec("cd {$id}; ./control.sh restart >> /dev/null 2>&1 & /n");
$sql->addPost('status', 1);
break;
}
$sql->update();
}
示例2: foreach
$new->addPost('admin', $admin);
$new->addPost('username', type::post('username'));
$new->addPost('password', userLogin::hash(type::post('password'), $salt));
$new->save();
echo message::success(lang::get('user_added'));
}
if (isset($_POST['delete'])) {
$ids = type::post('ids');
if (is_array($ids) && count($ids) >= 1) {
if (in_array(rp::get('user')->get('id'), $ids)) {
echo message::danger(lang::get('user_delete_own'));
} else {
foreach ($ids as $var) {
$sql = new sql();
$sql->setTable('user');
$sql->setWhere("id=" . $var);
$sql->delete();
}
echo message::success(lang::get('user_deleted'));
}
} else {
echo message::danger(lang::get('choose_user'));
}
}
$table = new table();
$table->addCollsLayout('25, 30%, *, 140, 100');
$table->addRow()->addCell("\n\t\t\t<input type='checkbox' id='all'>\n\t\t\t<label for='all'></label>\n\t\t", ['class' => 'checkbox'])->addCell(lang::get('name'))->addCell(lang::get('email'))->addCell(lang::get('username'))->addCell("");
$table->addSection('tbody');
$table->setSql('SELECT * FROM ' . sql::table('user'));
while ($table->isNext()) {
$id = $table->get('id');
示例3: addon
if (!$install) {
$sql->addPost('active', 0);
}
$sql->update();
echo message::success(lang::get('addon_save_success'));
}
}
if ($action == 'active') {
$addonClass = new addon($addon, false);
$active = $addonClass->isActive() ? 0 : 1;
if (!$addonClass->isInstall()) {
echo message::danger(sprintf(lang::get('addon_install_first'), $addon));
} else {
$sql = new sql();
$sql->setTable('addons');
$sql->setWhere('`name` = "' . $addon . '"');
$sql->addPost('active', $active);
$sql->update();
echo message::success(lang::get('addon_save_success'));
}
}
if ($action == 'help') {
$curAddon = new addon($addon);
?>
<div class="panel">
<div class="top">
<h3><?php
echo $curAddon->get('name');
?>
</h3>
</div>
示例4: sortTable
public static function sortTable($table, $sort, $where = '', $select = ['id', 'sort'])
{
if ($where) {
$where = ' WHERE ' . $where;
}
$update = new sql();
$update->setTable($table);
$i = 1;
$sql = new sql();
$sql->query('SELECT `' . $select[0] . '`, `' . $select[1] . '` FROM ' . self::table($table) . $where . ' ORDER BY `' . $select[1] . '` ASC')->result();
while ($sql->isNext()) {
if ($sort == $i) {
$i++;
}
$update->addPost($select[1], $i);
$update->setWhere($select[0] . '=' . $sql->get($select[0]));
$update->update();
$sql->next();
$i++;
}
}