Multiple automatic wheres

Asked

Viewed 51 times

0

I was seeing in the CodeIgniter that there is a way to insert several 'Where' into the class DB:

Example:

$this->db->where('id', 1)
     ->where('name', 'Jão')
     ->where('lastname', 'Fulaninho')
     ->get('users')
     ->result();

The point here is that where a few words are automatically inserted each new where that I put up where (...) or where (...) and so on.

What is called this form of programming in POO. For me to make my own classes that way.

  • 3

    I guess that’s it: What is Chaining of Methods?

  • 1

    Possible duplicate of What is Chaining of Methods?

  • @Virgilionovic did not, because there he asked what was chaining of methods, here I am asking 'what is called' this form of programming that I put up.

1 answer

1

Some have spoken of method linkages, and that’s correct. But I also think it’s important to mention that it can also be called Fluent Interface.

But speaking more specifically of Codeigniter’s Active Records, I think the easiest term for you to find references that help you create a similar feature would be: Sql Query Builder (Constructor de Query Sql).

See some sample libraries:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.