MySQL connect on PHP

前端 未结 4 1307
情书的邮戳
情书的邮戳 2021-01-23 19:57

what is the best way to connect PHP application on MySQL.

So far I had the below connection classes.

class Connection{
    private static $server = \"127         


        
4条回答
  •  再見小時候
    2021-01-23 20:37

    You can connect through data using PDO, here is an example

    setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        echo "Connected successfully"; 
    
        $stmt = $conn->prepare("SELECT * FROM todolist"); 
        $stmt->execute();
    
        }
    catch(PDOException $e)
        {
        echo "Connection failed: " . $e->getMessage();
        }
    ?>
    
    
    
    
    
    
    fetchAll() as $k=>$v){
         echo
       "\n";
    
    }
    
    
    ?>
    
    name type status
    {$v['name']} {$v['type']} {$v['status']}

提交回复
热议问题