I'm trying to implement Php Codeigniter model function that can count the number of left children and the number of right children for binary tree but i got this message error :
Error Number: 1062
Duplicate entry '4' for key 1 INSERT INTO 'mytable' (
members_id,members_username,members_password,)Filename: C:\AppServ\www\app\system\database\DB_driver.phpLine Number: 330
i use this function and i think i have some logic error .
function count(){
$query = $this->db->get('mytable');
foreach ($query->result() as $row) {
if ($row->id > 1) {
$Right_Child= $this->insert_to_right($row, $row->id);
$Left_child = $this->insert_to_left($row, $row->id);
$count1=0;
$count2=0;
if($Left_child!=NULL){
for($count1;$count1<=10;$count1++)
{
$count1=$htis->Left_child->count();
echo 'Left_child';
}
if($Right_Child!=NULL){
for($count2;$count2<=10;$count2++){
$count2= $this ->Right_Child->count();
return $count2;
echo 'Right_Child';
if($count1==$count2){
echo'tree';
}
}
}
}
}
members_id- Amin Adha