I love how I can feed the CodeBuilder a table out of my data base and it’ll build 90 percent of the code for me, I mainly just need to rearrange it to what I need. The implied architecture is one table per a module. Well now I need to perform my second “join” ever… and the first one was confusing to get right. I’m still not sure about the whole left or right join, but that’s for another forum. I created a second module, just to copy the model file back to the first module and then call both models in the constructor…
public function __construct()
{
parent::__construct();
$this->auth->restrict('Work_Log.Reports.View');
$this->load->model('customers_model', null, true);
$this->load->model('work_log_model', null, true);
$this->lang->load('work_log');
Assets::add_css('flick/jquery-ui-1.8.13.custom.css');
Assets::add_js('jquery-ui-1.8.13.min.js');
Template::set_block('sub_nav', 'reports/_sub_nav');
Assets::add_module_js('work_log', 'work_log.js');
}
after loading both models I attempt to “join” them…
public function index()
{
// Deleting anything?
if (isset($_POST['delete']))
{
$checked = $this->input->post('checked');
if (is_array($checked) && count($checked))
{
$result = FALSE;
foreach ($checked as $pid)
{
$result = $this->work_log_model->delete($pid);
}
if ($result)
{
Template::set_message(count($checked) .' '. lang('work_log_delete_success'), 'success');
}
else
{
Template::set_message(lang('work_log_delete_failure') . $this->work_log_model->error, 'error');
}
}
}
$this->work_log_model->select('*');
$this->customers_model->from('bf_users');
$this->work_log_model->join('bf_daily_gol', 'Property_ID = Property_ID');
$records = $this->work_log_model->where('Customer_ID', $this->current_user->Customer_ID)->order_by('Done', 'desc')->find_all();
Template::set('records', $records);
Template::set('toolbar_title', 'Manage Work Log');
Template::render();
}
So far I’m getting a 1066 Error… Not unique table/alias: ‘bf_daily_gol’
Can anyone suggest how I should be doing this?