コード例 #1
0
 /**
  * 获取外键数据来源
  * @param string $key 指定key获取
  * @return array|string 获取到的数据或指定key的值
  */
 public function getSubmodule($key = '')
 {
     $submoduleDB = new SubmoduleModelDB();
     $data = array();
     if (is_array($key)) {
         if (!empty($key)) {
             $sql = "SELECT `id`,`name` FROM `" . $submoduleDB->getTableName() . "` WHERE `id` IN ?";
             $submoduleModelDBArr = $submoduleDB->getData($sql, array($key));
             $data = Common::createArr($submoduleModelDBArr, 'id', 'name');
         }
     } else {
         if ($key === '') {
             $sql = "SELECT `id`,`name` FROM `" . $submoduleDB->getTableName() . "`";
             $submoduleModelDBArr = $submoduleDB->getData($sql);
             $data = Common::createArr($submoduleModelDBArr, 'id', 'name');
         } else {
             $sql = "SELECT `name` FROM `" . $submoduleDB->getTableName() . "` WHERE `id` = ?";
             $data = $submoduleDB->getFirst($sql, array($key));
         }
     }
     return $data;
 }
コード例 #2
0
 public function getGrapheDetail()
 {
     $ids = explode(',', $_GET['ids']);
     $submoduleDB = new SubmoduleModelDB();
     $name = $submoduleDB->getData('SELECT id, name FROM `' . $submoduleDB->getTableName() . '` WHERE id IN ?', array($ids));
     Message::showSucc('模块名', $name);
 }