Welcome Guest, Not a member yet? Register   Sign In
Active record minimal length?
#1

[eluser]Unknown[/eluser]
How to get sql results only if the field length is more then 4 chars?
I can't find it in the active record help.
If somebody knows the solution, let me know!
thanks.
#2

[eluser]Eric Barnes[/eluser]
I am not sure I follow. Maybe write out the sql statement you want and then we can help you convert it to AR.
#3

[eluser]hmayag[/eluser]
If you need to validate user input before passing it to active record constructs, the appropriate place to do so is in the view and the controller (remember, CI is an implementation of the MVC pattern). I suggest you take a look at the form validation class help. You 'll find lots of example code.

If you are implementing validity checks in your database schema (depending on the application, this may be considered from overkill to absolutely necessary), then you have to provide according functionality db-server-side.

The later case is more a matter of schema design i.e. implementing model functionality in the db engine. If an application needs this level of sophistication and data control, personally I would use the CI model just as an interface (no logic) to pass obtained data to/from the controllers and do all the heavy lifting in the db-engine using stored procedures. This is because I feel more comfortable working with a db engine than because I am aware of any inherent weakness/problem of active record. It is largely a matter of style and preferences.
#4

[eluser]Unknown[/eluser]
Reading this your entry I have even noticed some new information which I haven’t known before. Thanks a lot for sharing this interesting post and I will be waiting for other great news from you in the nearest future.
#5

[eluser]TheBaron[/eluser]
The literal answer to your question.

Code:
$this->db->where('LENGTH(column) >', 4, false)->get('table');

Though I don't understand why you would need this.




Theme © iAndrew 2016 - Forum software by © MyBB