Welcome Guest, Not a member yet? Register   Sign In
Error SQl
#1

[eluser]Unknown[/eluser]
//The CODE:
function adminis()
{
$this->load->database();
$this->load->library('pagination');
$this->load->library('table');
$config['base_url']= 'http://localhost/index.php/site/adminis';
$config['total_rows']= $this->db->get('solicit')->num_rows();
$config['per_page']= 4;
$config['num_links']= 20;

$this->pagination->initialize($config);

$sql='SELECT * FROM solicit, respost WHERE solicit.id_solicit = respost.id_solicit';
$respost['respost']=$this->db->get($sql,$config['per_page'],$this->uri->segment(3));
$this->load->view('logged_in_adminisr',$respost);

}



//And the error is:

A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM solicitud, respuestas WHERE solicitud.id_solicitud = respuestas.id_solici' at line 2

SELECT * FROM (`SELECT` * FROM solicit, respost WHERE solicit.id_solicit = respost.id_solicit) LIMIT 4

// But the sql statement is correct and validate the sql client knows someone who gives this error
#2

[eluser]toopay[/eluser]
Read Active Record Class Section before you use it!
#3

[eluser]Unknown[/eluser]
It does not work for $ query = $ this-> db-> get ('mytable1', 'mytable2');
I will try with $ this-> db-> join (), when you get home
thanks for replying I will continue reading the Active Record Class to better understand their work XD
#4

[eluser]Aken[/eluser]
$this->db->get('text') is an Active Record method that will automatically generate the following:
Code:
SELECT * FROM `text`

If you want to custom write the entire SQL query yourself, do not use the get() method. That's why your SQL statement has two different SELECT statements. Instead, use $this->db->query('your query here')




Theme © iAndrew 2016 - Forum software by © MyBB