php - How to write this query in Laravel 4? -


i search net not find solution problem, codeigniter developer , started project in laravel

my query in codeigniter active record this:

public function show_brt($id = 0,$tax_cat_id,$lang="en")  {     $records = $this->db             ->select('                 t1.id,                 t1.date_received,                  t1.customer_name,                  t1.memo,                  t1.percent_tax_withheld,                  t1.gross_invoice_amount,                  t1.tax_amount_withheld,                  t1.net_amount_received,                  t1.tax_payment_date,                  t2.rate,                  t3.name_' . $lang. ' deposit_account'                 )             ->from('brt t1')             ->join('exchange_rate t2', 't2.id = t1.exchange_rate_id','left')             ->join('balance_sheet_accounts t3', 't3.id = t1.deposit_account_id','left')             ->where('t1.income_statement_account_id', $id)             ->where('t1.tax_cat_id',$tax_cat_id)             ->where('t1.company_id', $this->session->userdata('company_id'))             ->where('t1.fiscal_year_id', $this->session->userdata('fiscal_year_id'))             ->where('t1.user_id', $this->m_auth->get_user_id())             ->get();      if ($records->num_rows() > 0) {         return $records;     } } 

could 1 me how can write queries should safe sql injections in laravel eloquent or fluent.

try code: i'm ci. have done 1 migration. may not best solution. didn't test.

db::table('brt t1')      ->select('t1.id,                 t1.date_received,                  t1.customer_name,                  t1.memo,                  t1.percent_tax_withheld,                  t1.gross_invoice_amount,                  t1.tax_amount_withheld,                  t1.net_amount_received,                  t1.tax_payment_date,                  t2.rate,                  t3.name_' . $lang. ' deposit_account'             )      ->leftjoin('exchange_rate t2', 't2.id', '=', 't1.exchange_rate_id')      ->leftjoin('balance_sheet_accounts t3', 't3.id', '=', 't1.deposit_account_id')      ->where('t1.income_statement_account_id', '=',$id)      ->where('t1.income_statement_account_id','=', $id)      ->where('t1.tax_cat_id','=',$tax_cat_id)      ->where('t1.company_id','=', $this->session->userdata('company_id'))      ->where('t1.fiscal_year_id','=', $this->session->userdata('fiscal_year_id'))      ->where('t1.user_id','=', $this->m_auth->get_user_id())      ->get(); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -