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()
$this->load->model('customers_model', null, true);
$this->load->model('work_log_model', null, true);
after loading both models I attempt to "join" them...
public function index()
// Deleting anything?
$checked = $this->input->post('checked');
if (is_array($checked) && count($checked))
$result = FALSE;
foreach ($checked as $pid)
$result = $this->work_log_model->delete($pid);
Template::set_message(count($checked) .' '. lang('work_log_delete_success'), 'success');
Template::set_message(lang('work_log_delete_failure') . $this->work_log_model->error, 'error');
$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('toolbar_title', 'Manage Work Log');
So far I'm getting a 1066 Error... Not unique table/alias: 'bf_daily_gol'
Can anyone suggest how I should be doing this?
Well I'm not familiar with the CI ActiveRecord interface but after taking a glance at the docs it looks like Property_ID is ambiguous. In order to resolve the issue simply add the table name before each one.
$this->work_log_model->join('bf_daily_gol', 'bf_users.Property_ID = bf_daily_gol.Property_ID');
This topic is now closed. New replies are no longer allowed.