Question

Is it really possible to create database table dynamically in CodeIgniter because I can’t create it and couldn’t understand what i am doing wrong? My code is:

 $field2=array('Prom_Id' => array('type' => 'INT',
                  'constraint' => 8),
      'Date'  => array('type' => 'DATE',
               'constraint' => 8),

      'Desig_Id' => array('type' => 'INT',
                  'constraint' => 8),

      'Grade_Id' => array('type' => 'INT',
                  'constraint' => 8));

   $this->load->dbforge();
   $this->dbforge->add_field( $field2); 
   $this->dbforge->add_key('Prom_Id',TRUE);
   $this->dbforge->create_table('deed',TRUE);

This is not working.

Was it helpful?

Solution

CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
GRANT SELECT ON *.* TO 'jeffrey'@'localhost';
GRANT ALL ON db1.* TO 'jeffrey'@'localhost';

The first command creates the user. The second grants select on all databases and tables. The third command grants all access to all tables in db1.

To provide a specific user with a permission, you can use this framework:

GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;


 GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';

The asterisks in this command refer to the database and table (respectively) that they can access—this specific command allows to the user to read, edit, execute and perform all tasks across all the databases and tables.

Once you have finalized the permissions that you want to set up for your new users, always be sure to reload all the privileges.

  FLUSH PRIVILEGES;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top