Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Model VS Query Builder
#6

(03-30-2020, 01:27 PM)includebeer Wrote: Why is it confusing? For example find($id) will return the row your are asking. Why does it matter if it’s a call to the query builder, or if it’s a call to a model function, that will then call the query builder and return the result? I see those functions as “shortcut” to accomplish task we need to do often. Like fetching a row with its id.

I recognize that the model class seeks to accomplish a wide variety of tasks developers often need to do and make them simple. However, the fact that you can chain Query Builder methods and the Model’s CRUD methods tends to obscure the class relationships - which leads to confusion. If it's not confusing why do questions keep showing up on various forums along the lines of "Why is $model->like('somefield', 'someThing')->get()->getResult() returning deleted rows?" Obviously, it does matter if it’s a call to the query builder or to a model function. It requires more than a cursory reading of the documentation to truly understand how the various classes work together.
Reply


Messages In This Thread
RE: Codeigniter Model VS Query Builder - by dave friend - 03-31-2020, 08:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB