Welcome Guest, Not a member yet? Register   Sign In
Where does $this->model->update(????) get its params from when using the CI's Model?
#1

I've created a very clever dynamic RESTFul API where the resource it set dynamically ... BUT, I now face an issue when trying to update a resource. I can't seem to use the 'built in' update method, as the $id is now the resource (the table) and $data the id ...

Now, I set the table on the Model in the Controller's __construct method, so that it's set correctly in initialization. But I can't seem to figure out WHERE the 'built in' update method gets its parameters from; is it from the route?

I have these routes:

Code:
$routes->get('api/(:segment)', 'Api::index/$1');
$routes->get('api/(:segment)/(:segment)', 'Api::index/$1/$2');
$routes->put('api/(:segment)/(:segment)', 'Api::update/$1/$2');

I seem to need to skip the first 'segment' (which is dynamic and comes in as a resource) when updating (as the resource - the table - is set in the __construct). HOW do I SKIP parameters when using the UPDATE method?

I'm sending an object with a ID and DATA attributes, as in { id : 4, data: "serialized object" } ...
Reply


Messages In This Thread
Where does $this->model->update(????) get its params from when using the CI's Model? - by blaasvaer - 12-15-2020, 05:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB