Welcome Guest, Not a member yet? Register   Sign In
I have problem
#1

[eluser]ibnu drim[/eluser]
I’m sure this is something trivial but I’ve spent the last hour scratching my head on this one!

I have several functions in my Model that all look like this (that find various things):
this is my controller :
Code:
function post( $slug = FALSE )
    {
        if( empty( $slug ) )
            show_404();
            
        $this->load->model('model_posts');
        $this->load->model('model_gallery');
      //$posts = $this->model_gallery->getPosts();
        $posts = $this->model_gallery->getChild( $slug );
        
        $data = array(
            'contentPage'        =>    'gallery',
            'breadcrumb'        =>    $this->model_posts->createBreadCrumb(),
            'advTop'            =>  FALSE,
            'posts'             =>  $posts
        );
        
        ?>
        <pre>&lt;?php //echo print_r($posts); ?&gt;</pre>
        &lt;?php
        
        if( $posts )
        $data['show'] = $posts->title;
            
        $this->load->view('index', $data);
    }
this is my Model :
Code:
function getChild( $slug = FALSE )
    {
        $this->db->where('status', 1)
                 ->where('parent', 0)
                 ->where('slug', $slug)
                 ->from('gallery');
                
        $query = $this->db->get();
            
        $posts = array();
        foreach( $query->result() as $result )
        {
            $galler = array();
            
            #has Child?
            $child = $this->pagesHierarchy( $result->ID );
            if( $child )
            {
                foreach( $child->result() as $c )
                    $galler['child'][] = $c;
                    
            }    
                $galler['parent'] = $result;
                
                $posts[] = $galler ;
            
        }
        //return $posts ;
        return !count( $posts )? FALSE:$posts;
    }
    
    function pagesHierarchy( $idParent = FALSE )
    {
        if( !$idParent || empty( $idParent ) )
            return FALSE;
        
        $this->db->where('parent', $idParent)
                 ->from('gallery')
                 ->order_by('ID', 'ASC');
                
        $RES = $this->db->get();
        
        return $RES->num_rows() <= 0? FALSE:$RES;
    }

this is my View :
Code:
&lt;?php
    if( $posts ):
?&gt;
                    <table class="gallery-lists">
&lt;?php
        $count = 1; $tCount = 1;
        foreach( $posts as $post ):
            
            $primaryImg = $this->models->_unserialize( $post->image_primary );
            $secondaryImg = $this->models->_unserialize( $post->image_secondary );
            
            if( $count <= 1 ):
?&gt;                    
&lt;?php
            endif;
?&gt;
&lt;?php $slug = $post->slug ;
                                echo site_url( array('gallery', $slug ) ); ?&gt;

please help me solve this error.
Trying to get property of non-object & uninitialized string offset :0
Thank you
Ibnudrim


Messages In This Thread
I have problem - by El Forum - 07-18-2011, 05:33 AM
I have problem - by El Forum - 07-18-2011, 09:33 AM
I have problem - by El Forum - 07-18-2011, 09:49 AM
I have problem - by El Forum - 07-19-2011, 01:53 AM
I have problem - by El Forum - 07-19-2011, 01:24 PM
I have problem - by El Forum - 07-19-2011, 08:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB