Posts

Showing posts with the label active records

How To Update A Joined Tables Using Codeigniter's Active Record?

Codeigniter active tape doesn't let to update a joined tables. After trying diverse method as well as searching the solution, I accept institute the next solution which does the precisely same affair i.e. update the multiple bring together tables. By using next method, you lot tin update multiple tabular array using codeigniter active record. $this->db->set('a.firstname', 'Pekka'); $this->db->set('a.lastname', 'Kuronen'); $this->db->set('b.companyname', 'Suomi Oy'); $this->db->set('b.companyaddress', 'Mannerheimtie 123, Helsinki Suomi'); $this->db->where('a.id', 1); $this->db->where('a.id = b.id'); $this->db->update('table every mo a, table2 every mo b'); Sumber http://developer-paradize.blogspot.com

How To Empty Or Truncate Mysql Tabular Array Using Codeigniter Active Record?

If you lot desire to empty or truncate a mysql tabular array using Codeigniter active record, role the next code. To empty $this->db->empty_table(); This volition generate a delete SQL string too runs the query. // DELETE FROM mytable To truncate $this->db->from('mytable'); $this->db->truncate(); // or $this->db->truncate('mytable'); This volition generate a truncate SQL string too runs the query. // TRUNCATE mytable Source: http://www.learnhow2do.com/computer/internet/2013/04/13/learn-how-to-empty-or-truncate-table-using-codeigniter-active-record/ Sumber http://developer-paradize.blogspot.com

How To Bring Together Multiple Tables Inward Codeigniter?

By using CodeIgniter's Active Record class, yous tin forcefulness out only utilization the bring together method multiple times to bring together multiple tables. $this->db->select('*'); $this->db->join('table2', 'table2.ID = table1.ID'); $this->db->join('table3', 'table3.ID = table1.ID'); $this->db->from('table1'); Permits yous to write the JOIN component division of your query. If yous require a specific type of JOIN yous tin forcefulness out specify it via the 3rd parameter of the function. Options are: left, right, outer, inner, left outer, together with correct outer. $this->db->join('table4', 'table4.ID = table1.ID', 'left'); // Produces: LEFT JOIN table4 ON table4.ID = table1.ID Read to a greater extent than especial on https://ellislab.com/codeigniter/user-guide/database/active_record.html Sumber http://developer-paradize.blogspot.com

How To Display Search Results Amongst Multiple Tags Using Codeigniter Active Record?

Image
I was working on a tags organization inward CI and, what I require was to generate a interrogation that should entirely display posts alongside selected tags (i.e. entirely that accept the tags) equally an output. After searching many hours inward internet, I saw this amazing weblog alongside possible solutions. http://tagging.pui.ch/post/37027745720/tags-database-schemas Because of my database struture, i liked "Toxi Solution". The primary payoff of this solution is that it is to a greater extent than normalized than the other solutions, together with that you lot tin hand notice accept unlimited pose out of tags per post. Since I require to entirely exhibit posts that accept the tags. So I accept to produce Intersection (AND) query. Intersection (AND) Query for “bookmark+webservice+semweb” SELECT b.* FROM tagmap bt, bookmark b, tag t WHERE bt.tag_id = t.tag_id AND (t.name IN ('bookmark', 'webservice', 'semweb')) AND b.id = bt.bookmar...

How To Generate Dynamic Similar Clause Alongside Parentheses Using Codeigniter Active Record?

If you lot desire to brand dynamic too custom LIKE clause using Codeigniter active record, next business office volition endure useful. For Example The release of tags too values is unknown. Arrays are created dynamically. This business office tin help you lot to attain what you lot desire to it. //To add together parentheses to a greater extent than or less the LIKE clauses business office make_like_conditions (array $fields, $search_text) { $likes = array(); foreach ($fields equally $field) { $likes[] = "$field LIKE '%$search_text%'"; } furnish '('.implode(' || ', $likes).')'; } business office do_something() { $search_fields = array( 'field_1', 'field_2', 'field_3', ); $search_text = "apple"; $like_conditions = $this->make_like_conditions($search_fields, $search_text); $query = $this->db->from('sometable')->where($like_conditions)-...

How To Generate Dynamic Similar Clause Alongside Parentheses Using Codeigniter Active Record?

If you lot desire to brand dynamic too custom LIKE clause using Codeigniter active record, next business office volition endure useful. For Example The release of tags too values is unknown. Arrays are created dynamically. This business office tin help you lot to attain what you lot desire to it. //To add together parentheses to a greater extent than or less the LIKE clauses business office make_like_conditions (array $fields, $search_text) { $likes = array(); foreach ($fields equally $field) { $likes[] = "$field LIKE '%$search_text%'"; } furnish '('.implode(' || ', $likes).')'; } business office do_something() { $search_fields = array( 'field_1', 'field_2', 'field_3', ); $search_text = "apple"; $like_conditions = $this->make_like_conditions($search_fields, $search_text); $query = $this->db->from('sometable')->where($like_conditions)-...