[eluser]codedoode[/eluser]
I'm having trouble joining 2 tables together using. I've tried doing a google search as well as here, and I'm a bit clueless as to why this isn't working the way I want it too. Can someone please lend a helping hand?
THIS IS MY CONTROLLER
Code:
<?php
class Site extends CI_Controller
{
public function index()
{
$this->load->model('Site_model');
$config["base_url"] = base_url() . "/site/index";
$config["total_rows"] = $this->Site_model->record_count();
$config["per_page"] = 20;
$config["uri_segment"] = 3;
$choice = $config["total_rows"] / $config["per_page"];
$config["num_links"] = round($choice);
$this->pagination->initialize($config);
$page = ($this->uri->segment(3))? $this->uri->segment(3) : 0;
$data["results"] = $this->Site_model->fetch_submissions($config["per_page"], $page);
$this->load->view('list_view', $data);
}
THIS IS MY MODEL
Code:
<?php
class Site_model extends CI_Model {
public function record_count()
{
return $this->db->count_all("submissions");
}
public function fetch_submissions($limit, $start)
{
$this->db->limit($limit, $start);
$this->db->select('*');
$this->db->from('submissions');
$this->db->join('votes', 'votes.id = submissions.id');
$query = $this->db->get("submissions");
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
}
THIS IS MY ERROR MESSAGE
Code:
Error Number: 1066
Not unique table/alias: 'submissions'
SELECT * FROM (`submissions`, `submissions`) JOIN `votes` ON `votes`.`id` = `submissions`.`id` LIMIT 20
Filename: /Applications/MAMP/htdocs/ttaa/models/site_model.php
Line Number: 34