[eluser]Sanity11[/eluser]
Hi everybody.
I am new to using sqlite and CI. What I have made with CI is done with a MySql database. But now we are going to create a website for a server that only supports SqlLite. Right now I am testing how to set this up, but I am missing some realy trivial information and knowledge on how to do this.
I have the following database settings (the test is locally so there is no password or username).
Code:
$active_group = "default";
$active_record = TRUE;
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "";
$db['default']['password'] = "";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "sqlite";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
I have this controller:
Code:
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
$this->load->helper('form');
$this->load->helper('html');
$this->load->view('welcome_message');
}
function insertdata()
{
$this->load->model('sqlitetestmodel');
$this->load->helper('html');
//$insert_info['vnaam'] = $this->input->post('vnaam');
//$insert_info['anaam'] = $this->input->post('anaam');
$this->sqlitetestmodel->insertdata();
$this->load->view('welcome_message');
}
}
This is the model:
Code:
<?php
class Sqlitetestmodel extends Model
{
function Sqlitetestmodel()
{
parent::Model();
}
function insertdata()
{
$this->load->database();
$data = array(
'voornaam' => $this->input->post('vnaam'),
'achternaam' => $this->input->post('anaam')
);
$this->db->insert('testing', $data);
}
}
?>
And of coures a view page:
Code:
<html>
<head>
<title>Welcome to CodeIgniter</title>
</head>
<body>
<h1>SQLite testing</h1>
<?php echo form_open('welcome/insertdata'); ?>
<table>
<tr>
<td>
Voornaam:
</td>
<td>
<input type="text" name="vnaam" />
</td>
</tr>
<tr>
<td>
Achternaam:
</td>
<td>
<input type="text" name="anaam" />
</td>
</tr>
</table>
<input type="submit" value="insert">
</form>
</body>
</html>
This test is only meant to see how I can add data to the database.
Can someone help me set this up correctly?
Thanks in advance
.