Welcome Guest, Not a member yet? Register   Sign In
[sqlite] How can I use it?
#1

[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>

&lt;?php echo form_open('welcome/insertdata'); ?&gt;
<table>
    <tr>
        <td>
            Voornaam:
        </td>
        <td>
            &lt;input type="text" name="vnaam" /&gt;
        </td>
    </tr>
    <tr>
        <td>
            Achternaam:
        </td>
        <td>
            &lt;input type="text" name="anaam" /&gt;
        </td>
    </tr>
</table>

&lt;input type="submit" value="insert"&gt;

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;

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 Smile.


Messages In This Thread
[sqlite] How can I use it? - by El Forum - 05-25-2009, 05:29 AM
[sqlite] How can I use it? - by El Forum - 05-25-2009, 05:38 AM
[sqlite] How can I use it? - by El Forum - 05-25-2009, 05:44 AM
[sqlite] How can I use it? - by El Forum - 05-25-2009, 06:00 AM
[sqlite] How can I use it? - by El Forum - 05-25-2009, 06:20 AM
[sqlite] How can I use it? - by El Forum - 05-25-2009, 06:28 AM
[sqlite] How can I use it? - by El Forum - 05-25-2009, 06:57 AM
[sqlite] How can I use it? - by El Forum - 05-25-2009, 07:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB