codeigniter insert oracle error Filename: C:\xampp\htdocs\system\database\DB_driver.php Line Number: 330

StackOverflow https://stackoverflow.com/questions/23428909

質問

So i get this error when i try to insert in an oracle database. I think i have everything configured correctly, and im doing things right, but dont know where the problem is, cause i get no number error.

ERROR:

Error Number:
INSERT INTO "articulo" ("id", "titulo", "descripcion", "cuerpo") VALUES (1, 'titulo', 'descripcion', 'CUERPO')
Filename: C:\xampp\htdocs\system\database\DB_driver.php
Line Number: 330

Controller Class:

class Articulos extends CI_Controller {
function index(){
    //cargo el helper de url, con funciones para trabajo con URL del sitio
    $this->load->helper('url');
    $this->load->database();  
    //cargo el modelo de artículos
    $this->load->model('Articulo_model');

    //pido los ultimos artículos al modelo
    $this->Articulo_model->introducir_articulos();
}}

The function in the model class:

function introducir_articulos(){
    $data = array(
            'id'=>1,
           'descripcion'=>"descripcion",
           'cuerpo'=>"CUERPO",
           'titulo'=>"titulo"
        );

    $this->db->insert('articulo', $data); 

}

since this has just to insert, it has no views. anyway this is my conf file.

DATABASE.php

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'ci';
$db['default']['password'] = 'ci';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'oci8';
$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';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

I readed recently, some place dat it's no use to put a database name in the configuration when its based on oracle.

Any help will be welcomed.

ps:sorry about my english.

EDIT: Now i know WHY, but not how to fix it, seems like this directly gets this query:

INSERT INTO "articulo" ("id", "titulo", "descripcion", "cuerpo") VALUES (1, 'titulo', 'descripcion', 'CUERPO')

it's a quote matter, it shouldnt be putting quotes to the insert so it should be like this.

 INSERT INTO articulo (id, titulo, descripcion, cuerpo) VALUES (1, 'titulo', 'descripcion', 'CUERPO')

any tips?

RE-EDIT:

OK this is really insane,wasn't a quote problem, oracle seems to be case sensitive when u write querys from PHP(or at least from code igniter) I just put them in caps lock(as they are in oracle), and worked. so this is the final model's function:

function introducir_articulos(){
    $data = array(
            'ID'=>5,
            'TITULO'=>"titulo",
           'DESCRIPCION'=>"descripcion",
           'CUERPO'=>"CUERPO"

        );


    $this->db->insert("ARTICULO", $data); 

}

couldnt answer my own question, so i answered it here.

役に立ちましたか?

解決 2

OK this is really insane, oracle seems to be case sensitive when u write querys from PHP.(or at least from code igniter) just put them in caps lock, and worked.3 hours researching. so this is the final model's function:

function introducir_articulos(){
    $data = array(
            'ID'=>5,
            'TITULO'=>"titulo",
           'DESCRIPCION'=>"descripcion",
           'CUERPO'=>"CUERPO"

        );


    $this->db->insert("ARTICULO", $data); 

}

他のヒント

In your configuration "DATABASE.php" you've should complete this statement

$db['default']['database'] = '';
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top