PDO support for multiple queries (PDO_MYSQL, PDO_MYSQLND)

后端 未结 7 2296
长发绾君心
长发绾君心 2020-11-21 06:03

I do know that PDO does not support multiple queries getting executed in one statement. I\'ve been Googleing and found few posts talking about PDO_MYSQL and PDO_MYSQLND.

7条回答
  •  失恋的感觉
    2020-11-21 06:28

    Try this function : mltiple queries and multiple values insertion.

    function employmentStatus($Status) {
    $pdo = PDO2::getInstance();
    
    $sql_parts = array(); 
    for($i=0; $idbh->prepare("DELETE FROM employment_status WHERE userid = :userID; INSERT INTO employment_status (userid, status) VALUES ".implode(",", $sql_parts));
    $requete->bindParam(":userID", $_SESSION['userID'],PDO::PARAM_INT);
    for($i=0; $ibindParam(":val$i", $Status[$i],PDO::PARAM_STR);
    }
    if ($requete->execute()) {
        return true;
    }
    return $requete->errorInfo();
    }
    

提交回复
热议问题