Codeigniter -> function using empty_table

Codeigniter -> function using empty_table



I am trying to empty the tables but I was wondering have I got the function correct?



Model:


public function removeQuote()

$this->db->empty_table('companyDetails,hostingDetails,layoutDetails');



Controller:


public function submit()

$data['companyContact'] = $this->quote->getCompanyDetails()->companyContact;

$this->load->view('submit',$data);

$this->quote->removeQuote();



Error:


Table '_quote.companyDetails,hostingDetails,layoutDetails' doesn't exist

DELETE FROM `companyDetails,hostingDetails,layoutDetails`




2 Answers
2


/**
* Empty Table
*
* Compiles a delete string and runs "DELETE FROM table"
*
* @param string the table to empty
* @return object
*/
public function empty_table($table = '')



Apparently you can't do this


$this->db->empty_table('companyDetails,hostingDetails,layoutDetails');



Instead you will have to call empty_table three times:


empty_table


$this->db->empty_table('companyDetails');
$this->db->empty_table('hostingDetails');
$this->db->empty_table('layoutDetails');



You can always hack CodeIgniter DB_active_rec.php file so that it fits your needs.



In your controller you have to load the model first (if it's not auto loaded)


$this->load->model('quote'); // Assuming your model name is 'quote'



before you use the function from that model as you used in your controller as follows


$data['companyContact'] = $this->quote->getCompanyDetails()->companyContact;



and load the view at last, after all code has been executed even after following line


$this->quote->removeQuote();



Just checked in CI doc empty_table doesn't accept multiple table names.


CI


empty_table





maybe he first loaded it in his __construct (), is there really a method called empty_tables () in the Database class of CodeIgniter?
– novato
Apr 9 '12 at 0:37


__construct ()


empty_tables ()





I have got my model auto loaded and please see here: codeigniter.com/user_guide/database/active_record.html#delete
– Jess McKenzie
Apr 9 '12 at 0:40





Got it, thanks.
– The Alpha
Apr 9 '12 at 0:42





Ok, didn't know about that! but please show us your error log
– novato
Apr 9 '12 at 0:43





No, it doesn't, I have just seen it in CI system code
– novato
Apr 9 '12 at 0:49






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ