[eluser]theprodigy[/eluser]
when you look in the database, are the records being added to the table?
[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265702102"]when you look in the database, are the records being added to the table?[/quote]
as i looked at my database.. it wasn't added there. i can't understand what does the value in the item means??? is it that i don't have enough fields?? i attached the image of my maint_company table.
[eluser]theprodigy[/eluser]
Code: function savecompany_details($id) //Query for saving the company
{
$data['company_id'] = $id;
$this->db->insert('maint_company',$id);
echo $this->db->last_query(); // <------- insert this in your model for debugging. It will output the last query ran (your insert statement in this case)
return $this->db->insert_id();
}
[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265702795"] Code: function savecompany_details($id) //Query for saving the company
{
$data['company_id'] = $id;
$this->db->insert('maint_company',$id);
echo $this->db->last_query(); // <------- insert this in your model for debugging. It will output the last query ran (your insert statement in this case)
return $this->db->insert_id();
}
[/quote]
i have tried your script and i saw in my console this message:
Quote:INSERT INTO `erp_maint_company` (`company_code`, `company_name`) VALUES ('hfghrfh', 'hfghfgh'){"item":35}
it means that it was added right?? but i wander why is it not posting in my detail grid.. that confuses me a lot.
[eluser]theprodigy[/eluser]
maybe the problem now is not with the saving, but the selecting of the information.
[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265703117"]maybe the problem now is not with the saving, but the selecting of the information.[/quote]
i do think so, i have noticed my database that it was not updating even if i add to my other tables. maybe that's why i can't see the data i added in my database.
and i think this code is responsible for the data why it wasn't posted..
Code: $item = $this->input->post("item");
[eluser]theprodigy[/eluser]
Quote:and i think this code is responsible for the data why it wasn’t posted..
Code: $item = $this->input->post("item");
That line isn't doing anything other then setting a local variable to false (setting it to false, because $_POST['item'] doesn't exist). You aren't passing that line into anything, so it's not doing anything whatsoever.
show me the code that selects the data from the database, and show me the code that loops through that select query result and puts it into the jquery grid.
[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265703839"] Quote:and i think this code is responsible for the data why it wasn’t posted..
Code: $item = $this->input->post("item");
That line isn't doing anything other then setting a local variable to false (setting it to false, because $_POST['item'] doesn't exist). You aren't passing that line into anything, so it's not doing anything whatsoever.
show me the code that selects the data from the database, and show me the code that loops through that select query result and puts it into the jquery grid.[/quote]
if im not mistaken this is the code:
Code: function getDetailList($ids) //Show the list of registered user with company details
{
$id = $this->input->post('ids');
$page = $this->input->post('page');
$limit = $this->input->post('rows'); // get how many rows we want to have into the grid
$sidx = $this->input->post('sidx'); // get index row - i.e. user click to sort
$sord = $this->input->post('sord'); // get the direction
if (!$sidx) $sidx = 'sec_companyaccess.user_id'; // if we not pass at first time index use the first column for the index
if (!$sord) $sord = 'desc';
if (!$page) $page = 1;
if (!$limit) $limit = 25;
$start = (($page-1) * $limit);
$this->db->start_cache();
/* if(isset ($_REQUEST["sec_companyaccess.user_id"]))
$rowid = $_REQUEST["sec_companyaccess.user_id"];
else
$rowid = "";*/
$this->db->join('maint_company','sec_companyaccess.company_id=maint_company.company_id','left');
$this->db->join('sec_users ','sec_companyaccess.user_id=sec_users.user_id','left');
$this->db->from('sec_companyaccess');
$this->db->where("sec_companyaccess.user_id", $ids);
$count = $this->db->count_all_results();
// calculate the total pages for the query
if( $count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
// if for some reasons the requested page is greater than the total
// set the requested page to total page
if ($page > $total_pages) $page=$total_pages;
// calculate the starting position of the rows
$start = $limit * $page - $limit; // do not put $limit*($page - 1)
// if for some reasons start position is negative set it to 0
// typical case is that the user type 0 for the requested page
if($start <0) $start = 0;
$this->db->select("sec_companyaccess.company_access_id as pkey,sec_companyaccess.company_access_id, maint_company.company_code, maint_company.company_name,sec_companyaccess.company_id ");
$this->db->order_by($sidx,$sord);
//$this->db->limit($rp, $start);
$query = $this->db->get("sec_companyaccess");
$this->db->flush_cache();
$data['db'] = $query;
$data['page'] = $page;
$data['totalpages'] = $total_pages;
$data['totalrecords']=$count;
return $data;
}
[eluser]theprodigy[/eluser]
Quote:Code: $this->db->join('maint_company','sec_companyaccess.company_id=maint_company.company_id','left');
Code: $this->db->select("sec_companyaccess.company_access_id as pkey,sec_companyaccess.company_access_id, maint_company.company_code, maint_company.company_name,sec_companyaccess.company_id ");
You are selecting data from sec_companyaccess while joining maint_company. You are only inserting data into maint_company, not sec_companyaccess. If there is no corresponding company_id in sec_companyaccess, it won't pull the record.
[eluser]maria clara[/eluser]
[quote author="theprodigy" date="1265706673"] Quote:Code: $this->db->join('maint_company','sec_companyaccess.company_id=maint_company.company_id','left');
Code: $this->db->select("sec_companyaccess.company_access_id as pkey,sec_companyaccess.company_access_id, maint_company.company_code, maint_company.company_name,sec_companyaccess.company_id ");
You are selecting data from sec_companyaccess while joining maint_company. You are only inserting data into maint_company, not sec_companyaccess. If there is no corresponding company_id in sec_companyaccess, it won't pull the record.[/quote]
yes, i have figured it that i have a mistake in that because i wasn't saving the company_id in the sec_companyaccess table which it views. and im thinking how can i save the company_id in two tables???
is it here??
Code: function savecompany_details($id) //Query for saving the company
{
$data['company_id'] = $id;
$this->db->insert('maint_company',$id);
//echo $this->db->last_query();
return $this->db->insert_id();
}
or i should change
Code: $sec_exist = $this->User->getCompanyDetails($id);
to
Code: $sec_exist = $this->User->getCompany($data);
the getCompany function is this:
Code: function getCompany($data)//Query to get the company_id of the loggin in user
{
$this->db->where($data);
$this->db->join('maint_company erp_b','a.company_id=b.company_id','left');
return $this->db->get('sec_companyaccess erp_a')->result_array();
}
|