![]() |
How can I use a join to paginate the model? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: How can I use a join to paginate the model? (/showthread.php?tid=84799) Pages:
1
2
|
How can I use a join to paginate the model? - arslanturk - 11-10-2022 Hello everyone, I've been using ci4 for a long time. I am very pleased. Thank you. If I come to my question. Now I have a model and I'm paginating. But I need to join from other tables. and I want to do this with the model. How can I do ? Code Example : PHP Code: $search_by = $this->request->getget('search_by'); When I activate the //join line on the model, the system gives an error. I haven't been able to solve this issue for a long time. Can you write a full sample code based on the example I gave? Thank you from now. RE: How can I use a join to paginate the model? - arslanturk - 11-12-2022 I guess no one will answer this question? ![]() RE: How can I use a join to paginate the model? - kenjis - 11-12-2022 Your code does not work in others environments, so it is difficult to write sample code. I recommend you see the exact error message and do debug by yourself. Or showing the exact error message would make you get more feedback. RE: How can I use a join to paginate the model? - demyr - 11-12-2022 Yeah, your error message would be fine. It might sound weird or funny but can you please try your join lines without "customers".id ? As in the example below: PHP Code: ->join('contact', 'contact.customer_id = id', 'left') RE: How can I use a join to paginate the model? - arslanturk - 11-14-2022 Sharing the error I got : https://prnt.sc/DR8HyyNLic8l RE: How can I use a join to paginate the model? - kenjis - 11-14-2022 It seems your query is wrong. Check your query. RE: How can I use a join to paginate the model? - arslanturk - 11-22-2022 Hello there, There is nothing wrong with the query. I am writing for the query in my first message. I can't join the model and this is a very serious problem. The solution I'm looking for: There will be both where and join, order by and pagination. How can I do it ? Can you show me an example based on the first message? Thank you. RE: How can I use a join to paginate the model? - demyr - 11-22-2022 I had also asked it here before but there is no exact answer. Not only here but also on internet. So, I agree. This is a huge missing point for CI. Pagination with joins in models looks like impossible. RE: How can I use a join to paginate the model? - kenjis - 11-22-2022 Using Model::paginate() for SQL Join in CodeIgniter 4 | Welcome to Abdul Malik Ikhsan's Blog https://samsonasik.wordpress.com/2020/03/29/using-modelpaginate-for-sql-join-in-codeigniter-4/ Codeigniter 4 Pagination with join tables showing error - Stack Overflow https://stackoverflow.com/questions/65275626/codeigniter-4-pagination-with-join-tables-showing-error RE: How can I use a join to paginate the model? - demyr - 11-22-2022 If you have a GET method (url) for that page, due to a filter function of a form, then they are messed up and no result. Especially if you have also a where clause within this query. The point is, the thing I can easily do with pure PHP cannot be easily done with our framework. For an easy and consistent CodeIgniter way of query, the method in the model should end with a classsical CI way, for example, $query->getResult(); However, now we have to start our statement with a "return" which is "a solution" and in the end it is not working properly. This is not a framework design kenjis. We are not trying something exraordinary or we do not need anything which is required only for one project. As I said, when I try it with pure php it works well but with CI it doesn't. And I don't want to mess up my project working with two different sql styles. |