視圖
cdnauto/views/config/index
echo CHtml::dropDownList(
)
)
);
echo " ";
echo CHtml::dropDownList(
控制器
cdnauto/controllers/ConfigController
public function actionGetNodeServersByNodeName(){
// if(!Yii::app()
// throw new CHttpException(
$node_name = $_POST[
$nodeid = Node::model()
$server = GossServer::model()
//$server 為array類型
if(isset($server)){
foreach ($server as $k=>$v){
foreach($v as $kk => $vv){
echo CHtml::tag(
}
}
}else{
echo CHtml::tag(
}
}
模型
GossServer
/**
* 通過節點ID獲取該節點下所有的服務器名稱
* @author ysdaniel
*/
public static function getServerByNodeid($nodeid)
{
$sql = "SELECT name FROM OSS_Server WHERE nodeid =
///$sql = "SELECT name
$cmd = Yii::app()
$ret = $cmd
if (!$ret){
throw new Exception("找不到這個節點對應的服務器");
}
return $ret;
}
Node
/**
* 通過nodename獲取nodeid名
* @author
*/
public static function getNodeId($name)
{
$sql = "SELECT id FROM OSS_Node WHERE name =
$cmd = Yii::app()
$ret = $cmd
if (!$ret){
return null;
//throw new Exception("找不到Node{$name}");
}
return $ret[
}
其它
數據表結構
效果
沒有選擇節點前
細節有空再補上了
From:http://tw.wingwit.com/Article/program/PHP/201311/21144.html