Need help with basic search query related stuff... |
[eluser]theif_of_always[/eluser]
I have a table in the database I am trying to query information from using a keyword value from a $_POST array. But, I am trying to combine active records: "like," "order_by (in asc order)" and "get" and I keep getting some kind of index error. I know how to do them individually (see below), but how would I use them together? I am passing the post array to this function as the method argument. And I want to return query object to calling function. Oh, and I am still a little fuzzy on what the "like" active record does. I read the definition provided by CI and wasn't sure what it was doing. Can someone explain it to me in layman's terms? Any help appreciated. Thanks. Code: public function search_books($post)
[eluser]Aken[/eluser]
You shouldn't pass query parameters directly from the $_POST array. Sanitize it before using it. LIKE is a pattern search, rather than an equality comparison (= or !=). http://theopentutorials.com/tutorials/my...-operator/ Code: $this->db->order_by('bookTitle', 'ASC');
[eluser]theif_of_always[/eluser]
here is my code: Code: public function search_books($post) Here is the error I get: A PHP Error was encountered Severity: Notice Message: Undefined index: bookTitle Filename: models/searchmodel.php Line Number: 10
[eluser]weboap[/eluser]
Code: $query = $this->db->get_where('bookInformation', array('bookTitle'=>$post['bookTitle']) ); now your issue is in the function calling this model function, it look like you are passing an array but not specifying Code: $post['bookTitle'] = 'something';
|
Welcome Guest, Not a member yet? Register Sign In |