Welcome Guest, Not a member yet? Register   Sign In
I am currently using Codeigniter 4.1.1 how do you retrieve data from the $afterInsert
#1

I am currently using Codeigniter 4.1.1 how do you retrieve the returned data from the $afterInsert callback here are my codes
my question is how to get retrive and access the returned $data from the model inside my controller (I am fairly new to codigniter any help will be appreciated)

//controller
``
    public function newBlog(){

        if($this->request->getMethod() == 'post'){
            $model= new SampleBlogModel();
            $model->save($_POST);
        }

        echo view('SampleBlogView');
    }


``
//model
``
class SampleBlogModel extends Model{
    
    protected $table = 'testdata';
    protected $allowedFields = ['blogContent' , 'blogTitle'];
    protected $primaryKey = 'blogId';

    protected $afterInsert = ['checkName'];

    protected function checkName(array $data){
        return $data;
    }

    
}

``
Reply


Messages In This Thread
I am currently using Codeigniter 4.1.1 how do you retrieve data from the $afterInsert - by John mark bartholomon - 04-12-2021, 10:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB