php - How can I create a CRUD with Codeigniter using SQLite? -


i'm starting new project want use codeigniter sqlite. searched information , managed conect , data sqlite database have no idea of how can create crud table this, i'm trying same way did in past mysql buy not working.

here did:

config/database.php

$db['default'] = array(     'dsn'   => '',     'hostname' => '',     'username' => '',     'password' => '',     'database' => apppath.'/database/pasapalabra.sqlite',     'dbdriver' => 'sqlite3',     'dbprefix' => '',     'pconnect' => false,     'db_debug' => (environment !== 'production'),     'cache_on' => false,     'cachedir' => '',     'char_set' => 'utf8',     'dbcollat' => 'utf8_general_ci',     'swap_pre' => '',     'encrypt' => false,     'compress' => false,     'stricton' => false,     'failover' => array(),     'save_queries' => true ); 

config/autoload.php

$autoload['libraries'] = array('database'); 

models/modelo_prueba.php

<?php defined('basepath') or exit('no direct script access allowed');  class modelo_prueba extends ci_model  {      public function gettestdata() {         return $this->db->get('preguntas')->result();     } }  ?> 

controllers/welcome.php

public function __construct() {     parent::__construct();     $this->load->library("grocery_crud"); }  public function prueba() {          $this->load->model('modelo_prueba');         $dataset = $this->modelo_prueba->gettestdata();         $this->load->view('data_view', [             'dataset' => $dataset         ]);      } 

views/data_view.php

<h4>lets test data</h4> <?php     if($dataset) {         foreach($dataset $dataitem) {             echo $dataitem->definicion . "<hr>";         }     } ?> <h5>done!</h5> 

this worked me, shows correctly data in 'preguntas' database, i'm trying create crud mysql , it's working, shows database error.

the thing have changed code of above welcome.php

public function prueba() {      $crud = new grocery_crud();     $crud->set_table('preguntas');      $output = $crud->render();     $this->load->view("example.php", $output);  } 

the error shown in screen following:

a php error encountered  severity: warning  message: sqlite3::query(): unable prepare statement: 1, near "show": syntax error  filename: sqlite3/sqlite3_driver.php  line number: 129  backtrace:  file: c:\xampp\htdocs\pasapalabra_isidro\application\models\grocery_crud_model.php line: 436 function: query  file: c:\xampp\htdocs\pasapalabra_isidro\application\libraries\grocery_crud.php line: 48 function: get_field_types_basic_table  file: c:\xampp\htdocs\pasapalabra_isidro\application\libraries\grocery_crud.php line: 1567 function: get_field_types  file: c:\xampp\htdocs\pasapalabra_isidro\application\libraries\grocery_crud.php line: 4507 function: showlist  file: c:\xampp\htdocs\pasapalabra_isidro\application\controllers\welcome.php line: 38 function: render  file: c:\xampp\htdocs\pasapalabra_isidro\index.php line: 315 function: require_once   database error occurred  error number: 0  not error  show columns `preguntas`  filename: c:/xampp/htdocs/pasapalabra_isidro/system/database/db_driver.php  line number: 691 

anyone knows happening? there isn't error database connection because previous code worked, it's grocery crud can't create crud of sqlite.

i'm working codeigniter 3.1.4 , created sqlite database sqlite manager (firefox) 0.8.3.1

thank answers.

hi have found solution grocery crud form post works sqlite3 have modify grocery curd library first copy sqlite3 model link

  1. http://www.grocerycrud.com/forums/topic/651-suport-for-sqlite3/
  2. this model extending grocery_crud_model, include grocery_crud_model in sqlite model.
  3. in grocery crud library find grocery_crud_model, loading model replace grocery_crud_sqlite3, , done. work perfect.

just remember have modify these lines manually on each update in future.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -