Welcome Guest, Not a member yet? Register   Sign In
Conditional Statement in SQL
#1

[eluser]JunlieF[/eluser]
Hello everyone,

I have a problem here, regarding about this syntax. sql...
anybody know how to correct this syntax?

$this->data['prints']= $this->print_model->department_id($dept)->betweenDates($to, $from);
//$sql = "SELECT * FROM prints WHERE request_id $dept AND date_printed BETWEEN {$from} AND {$to}";
#2

[eluser]Eduard Stankovic[/eluser]
try this one :

$sql = “SELECT * FROM prints WHERE request_id = '$dept' AND date_printed BETWEEN {$from} AND {$to}”;
#3

[eluser]JunlieF[/eluser]
@: Eduard Stankovic

Still wont work..

can u convert it into codeigniter format? the syntax is perfectly okay but... it needs to be the codeigniter.

$this->data[‘prints’]= $this->print_model->department_id($dept)->betweenDates($to, $from);
base on this codeigniter syntax I wonder about this "betweenDates" is this a built in or declaration hmmp... =(
#4

[eluser]JunlieF[/eluser]
function search(){
//redirect if user
if($this->data['role']==2 + 1)
redirect(base_url().'dashboard/layout');

if($_POST){
$this->load->model('print_model');
$this->load->model('');

$dept = $this->input->post('dept'); \\is the category for the department made of select tag in html
$from = $this->input->post('from'); \\date and time between to
$to = $this->input->post('to'); \\ date and time


$this->data['prints']= $this->($dept)->print_model->betweenDates($to, $from);

//$sql = “SELECT * FROM prints WHERE request_id = ’$dept’ AND date_printed BETWEEN {$from} AND {$to}”;
//$prints = PrintDetails::find_by_sql($sql);
//echo "<pre>";
//print_r($prints);

}

$this->load->view('search_view.php', $this->data);
}


how to convert into codeigniter?
#5

[eluser]Eduard Stankovic[/eluser]
replace $this->data[‘prints’]= $this->($dept)->print_model->betweenDates($to, $from);

by:

Code:
$query = $this->db->where("request_id", $dept)
                  ->where("date_printed BETWEEN {$from} AND {$to}")
                  ->get("prints");


$this->data[‘prints’] = $query->result_array();
#6

[eluser]JunlieF[/eluser]
@: Eduard Stankovie

Thanks for the help..

But it seems their is a error "Call to undefined method CI_DB_mysql_driver::get() in C:\xampp\htdocs\smdtc\application\controllers\dashboard.php"

I'll find away nor now.. &&




Theme © iAndrew 2016 - Forum software by © MyBB