寫了一段,php的插入代碼!

 寫了一段,sql的插入代碼!php

php用pdo寫入數據庫sql

//insert 插入表格資料
    
    $InsertSQL = sprintf("INSERT INTO `" . TAB . "link` "
                        . "(`title`,`url`,`logo`,`content`,`view`,`inpage`,`recom`) "
                        . "VALUES (%s,%s,%s,%s,%s,%s,%s)  "
                        , ':title'
                        , ":url"
                        , ":logo"
                        , ":content"
                        , ":view"
                        ,":inpage"
                        ,":recom");  
    $stmt =  $so->et_prepare($InsertSQL);
    
    $stv = array();  
     $stv['title'] = GetPdoValueString($_POST['title'], 'text'); 
      $stv['url']   = GetPdoValueString($_POST['url'], 'text');
       $stv['logo']   = GetPdoValueString($_POST['logo'], 'text');
        $stv['content'] = GetPdoValueString($_POST['content'], 'text');
         $stv['view']     = GetPdoValueString(isset($_POST['view']) ? "true" : "", "defined","1", "0");
          $stv['inpage']    = GetPdoValueString(isset($_POST['inpage']) ? "true" : "", "defined","1", "0"); 
           $stv['recom']     = GetPdoValueString(isset($_POST['view']) ? "true" : "", "defined","1", "0");  
            
            $stmt->bindValue("title", $stv['title']); 
           $stmt->bindValue("url",$stv['url']);
          $stmt->bindValue("logo",$stv['logo']);
         $stmt->bindValue("content",$stv['content']);
        $stmt->bindValue("view",$stv['view']);
       $stmt->bindValue("inpage",$stv['inpage'] );
      $stmt->bindValue("recom",$stv['recom']); 
     $stmt->execute();
相關文章
相關標籤/搜索