Welcome Guest, Not a member yet? Register   Sign In
updata 'row +1'
#1

[eluser]mo2men[/eluser]
hi

when i update views row

i get in mysql 0 !!!!!!!!
but i want views +1

Code:
function update_scam(){
  
        $id =  $this->input->post('id');

         $data = array(
               'view' => 'view +1'
            );

            $this->db->where('id', $id);
            $query = $this->db->update('topic', $data);


            if($query){
                return TRUE;
                 }
       }
#2

[eluser]JHackamack[/eluser]
Have you tried echoing out your query with:
Code:
echo $this->db->last_query();
to ensure that the code is proper mysql?

Another way you can do it is using:
Code:
$this->db->query('UPDATE the_table SET the_field = the_field + 1 WHERE [your WHERE clause]');
In my opinion this looks a little cleaner, but thats just my opinion.
#3

[eluser]mo2men[/eluser]
ok

i use this query
$query = $this->db->query("UPDATE topic SET view = view +1 where row = $integer ");

and i get
Unknown column 'site.com' in 'where clause'

UPDATE scam SET report = report +1 where site = site.com

i think problem whit $integer

because when i use query without where

i get true query

help ?
how i can wrote this query true
#4

[eluser]Twisted1919[/eluser]
$this->db->set('view','view+1',FALSE)->where('row',$integer)->update('topic');
#5

[eluser]Pschilly[/eluser]
Last one is best option... That way it uses the built in cleaning of the query stuff.




Theme © iAndrew 2016 - Forum software by © MyBB