使用PHP插入SQL Server数据库

时间:2019-05-11 15:08:58

标签: php sql-server

我在一个班级有以下代码: 本质上,这些值是在流程处理程序文件中使用检索的,然后对其进行处理并“插入”到表中。但是我知道如何使用MySQL,但我知道它与SQL Server不同。我还通过另一个文件建立了与SQL Server的连接,在该文件中,它检查是否在try catch块中建立了连接。

文件名:Item.php

class name
{
    public function submit($dateCreated , $choice, $user, $mainD, $sideD, $otherD, $date){
        //below are fucntion that check if the parameters are either blank or in format
        $this->validateMainTextArea($mainD);
        $this->validateradioButtons($choice);
        $this->validateDateFormat($date);

        if(empty($this->errorArray)){
            return $this->insertItemDetails($dateCreated , $choice, $user, $mainD, $sideD, $otherD, $date);
        }
    }

    private function insertItemDetails($dateCreated , $choice, $user, $mainD, $sideD, $otherD, $date){

        //inserts into sql database

    }
}

文件名:process-handler.php 从同一页面的输入框中获取值。

<?php

if(isset($_POST['menuSubmit'])){
    //if register button wass pressed
    $firstDate = date("Y-m-d");
    $menuChoice = $_POST['iChoiceID'];
    $user = $_SESSION['userID'];
    $main =  $_POST['txtMain'];
    $side =  $_POST['txtSide'];
    $other =  $_POST['txtAlternative'];
    $secondDate =  $_POST['itemDate'];

    $wasSuccessful = $menuItems->submit($firstDate, $Choice, $user, $main, $side, $other, $secondDate );
    if ($wasSuccessful == true){
        echo("Items have been processed! Check in vservices for outcome.");

    }
}
?>

0 个答案:

没有答案