2
私は親の子関係を取得しようとしていますが、それを成功させることを試みていますが、私は子供のレベルがどのようなものかを特定する方法が固まっています。ここでchlidのレベルは何ですか?
は私のコードの下
public function getDownline($userid = null) {
$category_data = array();
$where = array('parent_id' => $userid);
$this->db->where($where);
$category_query = $this->db->get('users')->result();
$category_data = array();
foreach ($category_query as $category) {
$category_data[$category->id] = array($category);
$children = $this->getDownline($category->id);
if ($children) {
$category_data[$category->id]['children'] = $children;
}
}
return $category_data;
}
は、私は私はあなたがこの中にやるべきだと思う。この形式で出力
[1136] => Array
(
[0] => stdClass Object
(
[id] => 1136
[gid] => 4
[parent_id] => 1112
[username] => test
[email] => [email protected]
[name] => test
[status] => 1
[registerd] => 2017-04-20 08:49:25
[last_login] => 2017-04-21 10:42:25
[password] => 4eca045dfa240f56a1f9d45eaa53b71c6eccd6a7
[tranjection_password] =>
)
[children] => Array
(
[1148] => Array
(
[0] => stdClass Object
(
[id] => 1148
[gid] => 4
[parent_id] => 1136
[username] => test_downline
[email] => [email protected]
[name] => test_downline
[status] => 1
[registerd] => 2017-04-21 10:42:56
[last_login] => 2017-04-21 11:08:00
[password] => 4eca045dfa240f56a1f9d45eaa53b71c6eccd6a7
[tranjection_password] =>
)
[children] => Array
(
[1150] => Array
(
[0] => stdClass Object
(
[id] => 1150
[gid] => 4
[parent_id] => 1148
[username] => test1_downline1
[email] => [email protected]
[name] => test1_downline1
[status] => 1
[registerd] => 2017-04-21 11:08:27
[last_login] => 0000-00-00 00:00:00
[password] => 4eca045dfa240f56a1f9d45eaa53b71c6eccd6a7
[tranjection_password] =>
)
)
)
)
[1149] => Array
(
[0] => stdClass Object
(
[id] => 1149
[gid] => 4
[parent_id] => 1136
[username] => test_downline2
[email] => kapil1[email protected]
[name] => test_downline2
[status] => 1
[registerd] => 2017-04-21 11:06:35
[last_login] => 0000-00-00 00:00:00
[password] => 4eca045dfa240f56a1f9d45eaa53b71c6eccd6a7
[tranjection_password] =>
)
)
)
)
取得中にエラーが動作するはずそのようmething:致命的なエラー:未定義のメソッドはstdClassに呼び出し::追加() –
をどのようにコントローラからgetDownline関数を呼び出していますか?あなたのコードplsを見せてください – sintakonte
'public function downline_income($ userId = null、$ offset = 0){ $ userId = user :: id(); $ downline = $ this-> user-> getDownline($ userId); ' –