Welcome Guest, Not a member yet? Register   Sign In
DB Create - Execute SQL Command

I have SQL script imported from phpmyadmin. What I wanted is to
execute that script using CI(if there are functions available).

Database Forge Class is pretty promising but what I wanted is
to execute the script(as string) directly.

What are available functions in Database Forge are creating/deleting/editing database and tables. No function is available for executing script with "create database, create table and insert data" SQL command.

Please help.

Thank you in advance.

you dont need to use database forge if you just want to run sql

This worked for me

$query = $this->db->query("CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,name VARCHAR(255));");

@progr@mmer thank you. but the sql command that i am referring includes creating the database.
Like this


CREATE DATABASE `_rms_lotto_db`
    CHARACTER SET 'latin1'
    COLLATE 'latin1_swedish_ci';

USE `_rms_lotto_db`;

# Structure for the `_users` table :

CREATE TABLE `_users` (
  `username` varchar(20) NOT NULL,
  `password` varchar(160) DEFAULT NULL,
  `type` enum('ad','rp') DEFAULT 'rp',
  PRIMARY KEY (`username`),
  UNIQUE KEY `username` (`username`)

Theme © iAndrew 2016 - Forum software by © MyBB