What i'm trying is validate a select query is processed successfully. With DB transaction we can validate INSERT , UPDATE, DELETE
like shown below in Codeigniter
$this->db->trans_begin();
//query
if($this->db->trans_status() == false){
return ['error' => 1, 'message' => 'Error massage'];
}
but it does not work with SELECT query. Is there any other ways to validate this.
Actually my select query will be like this in a scenario
SELECT (amount1+ 10 / 100) FROM test_table
the formula (amount1+ 10 / 100) in the above query will be decoded from the user input. some time a wrong input from user can be like this.
(amount1+ + 10 / 100)
so at the time select query will not execute.
@sintakonte the user input that i mentioned is a formula from a formula builder. so finally i did a simple trick to validate the query (formula). do an insertion or update to the table with the select query. In my scenario once i get the result from the select query i have to update a column in a table.
$this->db->trans_begin();
$this->db->query("UPDATE table2
JOIN (
SELECT (amount1+ 10 / 100) AS amnt, empID FROM test_table
) AS calculationTB
ON calculationTB.empID = table2.empID AND
SET fnTB.ssoEmployer=calculationTB.amnt");
if($this->db->trans_status() == false){
return ['error' => 1, 'message' => 'Error massage'];
}
$this->db->trans_commit();