CodeIgniter Forums
Change the status in the db - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Change the status in the db (/showthread.php?tid=68207)



Change the status in the db - tonny16 - 06-09-2017

Hello, 



I am a beginner with Codeigniter.
I want to change the status of my comments in order to validate them.
Let me explain: by default comments have a value of 0 and invisible to visitors.
I created an administrator space to manage comments.

I want to change the status from 0 to 1 simply.

I tried this: 

PHP Code:
this-> db-> where ('comment_id', $ comment_id);

This-> db-> update ('status''1');
This-> save (); 


I have a mistake:

Quote:Error Number: 1064

Syntax error near '1 =' 'WHERE `id_commentaire` =' 24 '' in line 1

UPDATE `status` SET 1 = '' WHERE` id_commentaire` = '24'

Filename: C: /wamp64/www/codeIgniter2/system/database/DB_driver.php

Line Number: 691


Thank you in advance for your answers

See you soon


RE: Change the status in the db - Paradinight - 06-09-2017

(06-09-2017, 08:42 AM)tonny16 Wrote: Hello, 



I am a beginner with Codeigniter.
I want to change the status of my comments in order to validate them.
Let me explain: by default comments have a value of 0 and invisible to visitors.
I created an administrator space to manage comments.

I want to change the status from 0 to 1 simply.

I tried this: 

PHP Code:
this-> db-> where ('comment_id', $ comment_id);

This-> db-> update ('status''1');
This-> save (); 


I have a mistake:

Quote:Error Number: 1064

Syntax error near '1 =' 'WHERE `id_commentaire` =' 24 '' in line 1

UPDATE `status` SET 1 = '' WHERE` id_commentaire` = '24'

Filename: C: /wamp64/www/codeIgniter2/system/database/DB_driver.php

Line Number: 691


Thank you in advance for your answers

See you soon

update to 3
PHP Code:
$data = array(
 
   'status' => 1
);

$this->db->where('comment_id'$comment_id);
$this->db->update('mytable'$data); 



RE: Change the status in the db - tonny16 - 06-09-2017

A big thank-you. It was so simple, I'm ashamed ...