How to update 2 columns with single post at the same time?

How to update 2 columns with single post at the same time?

pirvelipirveli Posts: 5Questions: 0Answers: 0
edited February 2017 in General

`$username = $_POST['username_reg'];
$password_reg=$_POST['password_reg'];
$password = md5($password_reg);
$user_reg_date = date("Y-m-d", time());

    $user_insert= $db->prepare("INSERT INTO users (username,password_tr,password,user_reg_date) VALUES (?,?,?,?)");
    $insert = $user_insert->execute(array($username,$password_tr,$password,$user_reg_date));
    $err = $user_insert->errorInfo();
    if (empty($err[2])) {
        echo 1;
    } else {

        echo "Error!";
    }`

How to update 2 columns with single post at the same time?

Replies

  • pirvelipirveli Posts: 5Questions: 0Answers: 0

    Please help me.

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    I'm not clear on how this relates to DataTables. It appears to be a generic PHP question?

    This is a DataTables forum and you'd be better asking general programming questions on StackOverflow or similar.

    Allan

  • pirvelipirveli Posts: 5Questions: 0Answers: 0

    Sorry. I could not tell right. How can I write the above SQL query using the Editor class?

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    If you are using the Editor PHP class you shouldn't need to write your own SQL queries. It will build the queries for you based on the data passed in from the client-side and the fields configured for the instance. The getting started documentation describes how you can use the Editor PHP class.

    Allan

  • pirvelipirveli Posts: 5Questions: 0Answers: 0
    edited February 2017

    Thank you, Allan.
    I have read how to use the editor class. I want to ask:
    How can we add another sql column to our Field :: inst ('password_reg')

    For example (Use of PDO):

    `$username = $_POST["username_reg"];
    $password_reg=$_POST["password_reg"];
    $password = md5($password_reg);// **How do I do this use editor class? Is it so : Field :: inst ('password')=md5( Field :: inst ('password_reg')) **

    $user_insert= $db->prepare("INSERT INTO users (username,password_tr,password) VALUES (?,?,?)");
    $insert = $user_insert->execute(array($username,$password_reg,$password));

    `

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Use a set formatter if you want to modify a value that is sent by the client-side.

    Allan

This discussion has been closed.