simple dbforge oddity causes newbie,s brain to fade - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: simple dbforge oddity causes newbie,s brain to fade (/showthread.php?tid=10987) |
simple dbforge oddity causes newbie,s brain to fade - El Forum - 08-21-2008 [eluser]ciPhil[/eluser] below is a simple script that is part of my learning of ci . I have no idea where even to think of looking. Is my code and logic ok ? Any ideas appreciated comments at end explain problem Cheers Phil <?php class Phil extends Controller { function Phil() { parent::Controller(); } function index() { $this->load->database(); $this->load->dbforge(); // a manual test is required with postgresql, IF EXISTS in version 8.2 If ($this->db->table_exists('phil')) { echo " table named phil exists"; echo "<br/>"; $this->dbforge->drop_table('phil'); echo "dropped table named phil"; }else{ echo "table did not exist"; } $fields = array( 'id'=>array( 'type'=> 'SERIAL'), 'mms'=>array( 'type'=> 'INT',//note no size required 'null'=> TRUE), 'testing'=>array( 'type'=>'VARCHAR', 'constraint'=>'32', 'null'=>FALSE), ); $this->dbforge->add_field($fields); $this->dbforge->create_table('phil'); If ($this->db->table_exists('phil')) { echo "<br/>"; echo "created table named phil"; // not working on first pass // ie . if no table at start // table IS created but NOT (echo) reported here // works ok, if table existed at start } } } ?> |