當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sql::setWhere方法代碼示例

本文整理匯總了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();
 }
開發者ID:kyroskoh,項目名稱:rokket,代碼行數:33,代碼來源:server.php

示例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');
開發者ID:DINKIN,項目名稱:rokket,代碼行數:31,代碼來源:user.php

示例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>
開發者ID:DINKIN,項目名稱:rokket,代碼行數:31,代碼來源:addons.php

示例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++;
     }
 }
開發者ID:DINKIN,項目名稱:rokket,代碼行數:21,代碼來源:sql.php


注:本文中的sql::setWhere方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。