PHP code example of dtmind / dtpdo

1. Go to this page and download the library: Download dtmind/dtpdo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dtmind / dtpdo example snippets



    
    $dbh = new DTPDO("mysql:host={$hostname};dbname={$dbname}", $username, $password);
    $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );        

    [..]

    

    
    $values= array(
                "id" => 0,
                "name" => "Charles", 
                "surname" => "Miller",
                "age" => "72",
                "city" => "Dallas"
        );
    
    $dbh->insertRecord("user",$values);

    

        
    $values= array(
                "id" => 4,
                "age" => "62",
                "city" => "Los Angeles"
        );
    
    $dbh->updateRecord("user",$values,"id");
    
    

        getValue("SELECT surname FROM user WHERE id=2");
    

        getValues("SELECT * FROM user WHERE id=2",PDO::FETCH_ASSOC);
    

        getListValue("SELECT * FROM user WHERE id>=2");
    

        getListValue("SELECT * FROM user WHERE id>=2", 0);
    

        getListValues("SELECT * FROM user")
    

        getListValues("SELECT * FROM user",PDO::FETCH_ASSOC,1)