Home  >  Article  >  Backend Development  >  PHP example of getting the ID numbers of all child and grandchild columns of a column_PHP tutorial

PHP example of getting the ID numbers of all child and grandchild columns of a column_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:34:551084browse

Copy code The code is as follows:

//@Get the sub-column ID number
private function sonCategoryIds($categoryID)
{
//@Initialize column array
$array[] = $categoryID;

do
{
$ids = '';
$temp = $this- >mysql->select('SELECT `id` FROM `pcb_article_category` WHERE `parentID` IN (' . $categoryID . ')');
foreach ($temp as $v)
{
$array[] = $v['id'];
$ids .= ',' . $v['id'];
}
$ids = substr($ids, 1, strlen($ids));
$categoryID = $ids;
}
while (!empty($temp));

$ids = implode(',', $array );

return $ids;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/748157.htmlTechArticleCopy the code The code is as follows: //@Get the sub-column ID private function sonCategoryIds($categoryID) { //@ Initialize column array $array[] = $categoryID; do { $ids = ''; $temp = $this-mys...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn