简体   繁体   中英

using mysql PASSWORD in a codeIgniter query

hello i need to use the "PASSWORD" fonction of mysql in my codeigniter query

here's my code :

$data = array(
        'id' => 'My id',
        'name' => 'My Name',
        'password' => 'My password'
);

$this->db->insert('mytable', $data);

// Produces : INSERT INTO mytable (id, name, password) VALUES ('My id', 'My name', 'My password');

but i want to produce this query : INSERT INTO mytable (id, name, password) VALUES ('My id', 'My name', PASSWORD('My password'));

help me please and i'm sorry for my bad english

Your question is unclear but give it ago

http://php.net/manual/en/function.password-hash.php

Database column password varchar 255

$new_password = password_hash($this->input->post('password'), PASSWORD_DEFAULT);

$data = array(
    'name' => $this->input->post('name'),
    'password' => $new_password
);

$this->db->insert('mytable', $data);

On the form to validate password

http://php.net/manual/en/function.password-verify.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM