Welcome Guest, Not a member yet? Register   Sign In
problem with Insert into db2.
#1

[eluser]buckboru[/eluser]
I am trying to run an insert statement with no luck. This is what i have
I am connecting to a db2 database on an Iseries/AS400


$this->db->insert('tstmis.blogscom',$_POST);
the resulting error shows
INSERT INTO tstmis`.`blogscom ("BLOG_ID", "AUTHOR", "TEXT") VALUES ('1', 'bug', 'in the code')

When i walk through debug and get into db2c_driver.php
function _insert($table, $keys, $values)
Code:
{
        return "INSERT INTO " . $this->_escape_table($table) . " (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
    }

when i put a display the value of $table is is 'tstmis.blogscom'
I can't figure out why i'm getting the quote around the . between tstmis and blogscom.
Any ideas?

Thanks
#2

[eluser]sybrex[/eluser]
Could you print_r($_POST) here?
#3

[eluser]buckboru[/eluser]
here is the information from the $_POST
Array ( [BLOG_ID] => 1 [AUTHOR] => kirby [TEXT] => a little bit of text )
#4

[eluser]GSV Sleeper Service[/eluser]
are you using active record to create your query? eg using $this->db->select()?
try adding FALSE as a second parameter to your select call.

from the user guide :
$this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.
#5

[eluser]buckboru[/eluser]
Yes, i suppose i am using active record.
below is my controller. I have tried using the false on my select, but my issue occurs on my insert. I tried added false to my insert also, with no effect and I don't see it as a possibility on the insert.
the error occurs in my Insert_comments function
<?php
// define blogger Controller Class

class Blogger extends Controller
{
function Blogger()
{
// load Parent controller
parent::Controller();

// load database class and connect to AS400(RGT)
$this->load->database();

// load helpers
$this->load->helper('url');
$this->load->helper('form');
}

// display all blog entries
function blogs()
{
$data['title']='My musings on the everyday goofiness of Kirby';
$data['result']=$this->db->get('tstmis.blogs');

// load blogger view
$this->load->view('blogs_view',$data);
}

// display all blog comments
function comments()
{

$data['title']= 'Blog Comments Listing';
$this->db->where('BLOG_ID',$this->uri->segment(3));
//$this->db->where('BLOG_ID',$id);
$data['result']=$this->db->get('tstmis.BLOGSCOM',false);
//load blog comments view
$this->load->view('blogs_comment_view',$data);
}

//insert new comments
function insert_comments()
{
print_r($_POST);
$this->db->insert('tstmis.blogscom',$_POST);
redirect('blogger/comments/'.$post['blog_id']);
}




Theme © iAndrew 2016 - Forum software by © MyBB