Welcome Guest, Not a member yet? Register   Sign In
Model problem
#11

[eluser]shinokada[/eluser]
Thanks for your help.

I followed your instruction and I have the following model.
Code:
<?php
class MMenu2 extends Model{

    function MMenu(){
    parent::Model();
    }

    function generateTree(&$tree, $parentid = 0) {
        
        $this->db->where ('parentid',$parentid);
        
        // $sql = 'SELECT * FROM menus WHERE parentid = $parentid';
        $res = $this->db->get('menus');
        if ($res->num_rows() > 0) {
            foreach ($res->result_array() as $r) {
                // push found result onto existing tree
                $tree[$r->id] = $r;
                // create placeholder for children
                $tree[$r->id]['children'] = array();
                // find any children of currently found child
                $this->generateTree($r->id, $tree[$r->id]['children']);
            }
        }
    }

}
?>

However this give an error of this.

Code:
A Database Error Occurred

Error Number: 1054

Unknown column 'Array' in 'where clause'

SELECT * FROM (`menus`) WHERE `parentid` = Array


Messages In This Thread
Model problem - by El Forum - 12-09-2009, 09:51 AM
Model problem - by El Forum - 12-09-2009, 09:57 AM
Model problem - by El Forum - 12-09-2009, 11:36 AM
Model problem - by El Forum - 12-09-2009, 11:47 AM
Model problem - by El Forum - 12-09-2009, 02:35 PM
Model problem - by El Forum - 12-09-2009, 02:54 PM
Model problem - by El Forum - 12-10-2009, 12:16 AM
Model problem - by El Forum - 12-10-2009, 12:21 AM
Model problem - by El Forum - 12-10-2009, 12:29 AM
Model problem - by El Forum - 12-10-2009, 12:46 AM
Model problem - by El Forum - 12-10-2009, 12:54 AM
Model problem - by El Forum - 12-10-2009, 12:59 AM
Model problem - by El Forum - 12-10-2009, 01:15 AM
Model problem - by El Forum - 12-10-2009, 01:23 AM
Model problem - by El Forum - 12-10-2009, 01:26 AM
Model problem - by El Forum - 12-10-2009, 01:30 AM
Model problem - by El Forum - 12-10-2009, 02:35 AM
Model problem - by El Forum - 12-10-2009, 08:28 AM
Model problem - by El Forum - 12-10-2009, 08:47 AM
Model problem - by El Forum - 12-10-2009, 09:43 AM
Model problem - by El Forum - 12-10-2009, 11:41 AM
Model problem - by El Forum - 12-10-2009, 12:20 PM
Model problem - by El Forum - 12-10-2009, 02:09 PM
Model problem - by El Forum - 12-10-2009, 02:29 PM
Model problem - by El Forum - 12-10-2009, 03:01 PM
Model problem - by El Forum - 12-10-2009, 05:58 PM
Model problem - by El Forum - 12-10-2009, 07:23 PM
Model problem - by El Forum - 12-10-2009, 08:53 PM
Model problem - by El Forum - 12-11-2009, 01:00 AM
Model problem - by El Forum - 12-11-2009, 01:07 AM
Model problem - by El Forum - 12-11-2009, 02:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB