+ Add comment and params type.

This commit is contained in:
caoyanyi
2023-09-15 09:46:01 +08:00
parent 83e46145c1
commit 70e61fc3e2
3 changed files with 11 additions and 11 deletions
+5 -3
View File
@@ -152,14 +152,15 @@ class programModel extends model
}
/**
* 根据项目集ID列表获取项目集信息。
* Get program pairs by id list.
*
* @param string|array $programIDList
* @param string $orderBy
* @param array $programIDList
* @param string $orderBy
* @access public
* @return array
*/
public function getPairsByList($programIDList = '', $orderBy = 'order_asc')
public function getPairsByList(array $programIDList = array(), string $orderBy = 'order_asc'): array
{
return $this->dao->select('id, name')->from(TABLE_PROGRAM)
->where('id')->in($programIDList)
@@ -223,6 +224,7 @@ class programModel extends model
}
/**
* 根据查询ID获取项目集列表。
* Get program list by search.
*
* @param string $orderBy
+4 -6
View File
@@ -33,12 +33,10 @@ pid=1
*/
$programTester = new programTest();
$programIdList = array('1', '1,2,3', array(1), array(1,2,3), '', '0', '11');
$programIdList = array(array(1), array(1,2,3), '', '0', '11');
r($programTester->getPairsByListTest($programIdList[0])) && p('1') && e('项目集1'); // 通过字符串'1'获取项目集名称
r($programTester->getPairsByListTest($programIdList[1])) && p('1,2,3') && e('项目集1,项目集2,项目集3'); // 通过字符串'1,2,3'获取项目集名称
r($programTester->getPairsByListTest($programIdList[2])) && p('1') && e('项目集1'); // 通过数组array(1)获取项目集名称
r($programTester->getPairsByListTest($programIdList[3])) && p('1,2,3') && e('项目集1,项目集2,项目集3'); // 通过数组array(1,2,3)获取项目集名称
r($programTester->getPairsByListTest($programIdList[4])) && p('') && e('0'); // 通过id为空获取项目集名称
r($programTester->getPairsByListTest($programIdList[5])) && p('') && e('0'); // 通过id=0获取项目集名称
r($programTester->getPairsByListTest($programIdList[6])) && p('') && e('0'); // 通过id=11获取项目集名称
r($programTester->getPairsByListTest($programIdList[2])) && p('') && e('0'); // 通过id为空获取项目集名称
r($programTester->getPairsByListTest($programIdList[3])) && p('') && e('0'); // 通过id=0获取项目集名称
r($programTester->getPairsByListTest($programIdList[4])) && p('') && e('0'); // 通过id=11获取项目集名称
+2 -2
View File
@@ -51,9 +51,9 @@ class programTest
* @access public
* @return array
*/
public function getPairsByListTest($programIDList = '')
public function getPairsByListTest($programIDList = array())
{
return $this->program->getPairsByList($programIDList);
return $this->program->getPairsByList((array)$programIDList);
}
/**