Welcome Guest, Not a member yet? Register   Sign In
Is there any way to check before call the $this->db->update() method, Is where condition set or not?
#1

[eluser]Sarwar CSE[/eluser]
Is there any way to check before call the $this->db->update() method is where condition is set or not?

like
Code:
// here i want to check , IS where condition  set or not?...
$this->db->update("table_name");

Please advice me ...
#2

[eluser]qcsites[/eluser]
hmmm... something like this???
Code:
if($varA == $varB) {
   $this->db->update("table_name");
} else {
   // Do something else?
   echo 'No update performed';
}

If you are checking on an input posted from a form
Code:
if(!$this->input->post('form_field') {
   // Form field is not set
   echo 'No update performed';
} else {
   // Form field is set  
   $this->db->update("table_name");
}
#3

[eluser]Sarwar CSE[/eluser]
Thanks Robert Rothardt for replay

Is there any method of $this->db where i can check there the no where condition set.

Thanks
Sarwar
#4

[eluser]Mirge[/eluser]
If you are wanting to view the query BEFORE it gets executed to check to see if a WHERE clause is found, you can use:

Code:
$query = $this->db->_compile_select();
// now you can look at $query to see if a 'WHERE' clause is found.

Note that $this->db->get() uses this method... not generally something you call directly.
#5

[eluser]Sarwar CSE[/eluser]
[quote author="Mirge" date="1347985483"]If you are wanting to view the query BEFORE it gets executed to check to see if a WHERE clause is found, you can use:

Code:
$query = $this->db->_compile_select();
// now you can look at $query to see if a 'WHERE' clause is found.

Note that $this->db->get() uses this method... not generally something you call directly.[/quote]
Thanks Mirge

Is there any way to extend the db class?
Like core class(Controller,Model)
Thanks
Sarwar Hasan




Theme © iAndrew 2016 - Forum software by © MyBB