Insert Help |
[eluser]kre8ivdesigns[/eluser]
I have a two column table called features Code: CREATE TABLE `features` ( And during install I want to add the features automcatically. Code: INSERT INTO (`features`) VALUES ('Air Conditioning','Alarm','Balcony','Cable/Satellite','Carpeted Floors', 'Disposal','Dishwasher','Fireplace','Gas Range','Hardwood Floors','Microwave','Patio/Deck','Tiled Shower','Washer/Dryer','Waterfront','Wheelchair Access Whats the easiest way with Codeigniter Active Record. Thanks.
[eluser]toopay[/eluser]
Code: // In controller
[eluser]Madoc[/eluser]
Your insert synthax is wrong. I believe that that correct synthax for quick insert is: Code: INSERT INTO (`features`) VALUES ('Air Conditioning'),('Alarm'),('Balcony'),('Cable/Satellite'),('Carpeted Floors'); I do not think using Active records is that relevant in this case (hard coded inserts). reference to mysql insert: http://dev.mysql.com/doc/refman/5.5/en/insert.html
[eluser]toopay[/eluser]
[quote author="Madoc" date="1303572429"]Your insert synthax is wrong. I believe that that correct synthax for quick insert is: Code: INSERT INTO (`features`) VALUES ('Air Conditioning'),('Alarm'),('Balcony'),('Cable/Satellite'),('Carpeted Floors'); What you mean wrong? Its a valid synthax. And if you want to use general SQL statement, it should be Code: INSERT INTO features VALUES (NULL,'values_1'),(NULL,'values_2'),(NULL,'values_3'); Code: INSERT INTO features (feature) VALUES ('values_1'),('values_2'),('values_3'); [quote author="Madoc" date="1303572429"] I do not think using Active records is that relevant in this case (hard coded inserts).[/quote] Why not relevant? AR, in codeigniter, is the safest way to insert sql statement and makes your code cleaner!
|
Welcome Guest, Not a member yet? Register Sign In |