0

So i am new to codeigniter, what i want to accomplish is to create a new database using the dbforge class by providing the parameters such as the name of the database, password and the username of this new created database. so far i have been able to create the database, but i want the username and password to be specified for this database too. How do i accomplish this.

so far i have this function

 public function dbcreate($db, $user, $pwd)
{
    $this->dbforge->create_database($db);
}

how do i go about incorporating the $user and $password within the newly created database.

1

1 Answer 1

0
    $fields = array(
                        'id' => array(
                                                 'type' => 'INT',
                                                 'unsigned' => TRUE,
                                                 'auto_increment' => TRUE
                                          ),
                        'username' => array(
                                                 'type' => 'VARCHAR',
                                                 'constraint' => '100',
                                          ),
                        'password' => array(
                                                 'type' =>'VARCHAR',
                                                 'constraint' => '100',

                                          ),

                );

    $this->dbforge->add_field($fields);
    $this->dbforge->create_table('users', TRUE);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @CristianR for your answer. the code you have provided is for creating a table. But what i want is to create the database with its username and password. for example when you want to create a database with php, normally you would provide the name of the database you wan to create, its passsword along with the username. now i want to accomplish that with codeigniter. thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.