Rajan
Rajan

Reputation: 2425

CONCAT and UPDATE in codeigniter php

Hi I am trying to execute this query:

If I get anything in POST['domain'] then I want to update the md_user field for each user in the Table.

UPDATE NECOFFICE_users SET md_user = md5(concat(ext,'@192.168.50.1')) WHERE site_key = 'EB22-0000'

This query runs perfectly fine in PHPMYADMIN

And My Active Record Code is :

$user_table = $this->session->userdata('user_table');
$string_md = $this->input->post('domain');


$this->db->set("md_user",md5("CONCAT('ext',@$string_md)"));
$this->db->where('site_key', $site_session);
$this->db->update($user_table);
echo $this->db->last_query();

Now this what should be my code to perform the above query in codeigniter ?

Upvotes: 1

Views: 1163

Answers (1)

Farkie
Farkie

Reputation: 3337

It looks like you're using the PHP MD5 function, instead of MySQL's:

$this->db->set("md_user",array("md5(CONCAT('ext',@{$string_md}))"), FALSE);

Try that, looks like it should work.

Edit:

After looking up CI's set method, you might be better just building it up without using MySQL's functions:

$this->db->set("md_user",md5('ext@' . $string_md));

Upvotes: 1

Related Questions