new records from database not showing up?
- Single Page
Posted 26 April 2012 - 19:42 PM
I've looked at my code and it seems okay, and I've done sql queries on the database and it finds the record but when I search on the crud table in the view it says there are no items to display. But at the bottom of the table it says the it is showing 1 of 1 records.
This is the code I was using to make the table:
[php] $this->load->model('location_model');
$data['account_num'] = $this->location_model->get_user_account_num();
$this->load->view('new_header', $data);
$this->load->view('new_top_menu', $data);
$crud = new grocery_CRUD();
$crud->set_table('location');
$crud->set_model('location_crud_model');
$crud->columns('location_main_id','name','city','state','lease','meter_rental','maintenance','fee','total','postage','spend_ratio');
$crud->display_as('location_code','Location Code');
$crud->display_as('meter_rental','Meter Rental');
$crud->display_as('total','Total Expense');
$crud->display_as('spend_ratio','Spend Ratio');
$crud->display_as('maintenance','Maint.');
$crud->unset_operations();
$crud->where('location_main_id', $data['account_num']);
$output = $crud->render();
$this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
$this->load->view('location_list', $output);
$this->load->view('new_footer', $data);
[/php]
And my set model code is:
[php]<?php
class Location_crud_model extends grocery_Model
{
function get_list()
{
if($this->table_name === null)
return false;
$select = "{$this->table_name}.*";
// ADD YOUR SELECT FROM JOIN HERE <------------------------------------------------------
$select .=", location.location_main_id, location.location_code, location.name, location.city, location.state, location_summary.lease, location_summary.meter_rental, location_summary.maintenance, location_summary.fee, location_summary.total, location_summary.postage, location_summary.spend_ratio";
// for example $select .= ", user_log.created_date, user_log.update_date";
if(!empty($this->relation))
foreach($this->relation as $relation)
{
list($field_name , $related_table , $related_field_title) = $relation;
$unique_join_name = $this->_unique_join_name($field_name);
$unique_field_name = $this->_unique_field_name($field_name);
if(strstr($related_field_title,'{'))
$select .= ", CONCAT('".str_replace(array('{','}'),array("',COALESCE({$unique_join_name}.",", ''),'"),str_replace("'","\\'",$related_field_title))."') as $unique_field_name";
else
$select .= ", $unique_join_name.$related_field_title as $unique_field_name";
if($this->field_exists($related_field_title))
$select .= ", {$this->table_name}.$related_field_title as '{$this->table_name}.$related_field_title'";
}
$this->db->select($select, false);
// ADD YOUR JOIN HERE for example: <------------------------------------------------------
$this->db->join('location_summary','location_summary.location_id = location.location_id');
// $this->db->join('user_log','user_log.user_id = users.id');
$results = $this->db->get($this->table_name)->result();
return $results;
}
}
?>[/php]
Normally it would pop up like this:
[attachment=133:good.png]
But when I search this comes up:
[attachment=134:bad.png]
I'm really confused as to why this is happening, so if anyone can shed some light onto this topic I'd really appreciate it.
Posted 27 April 2012 - 05:33 AM
Posted 04 May 2012 - 15:13 PM