PHP code example of ymvas / ymsql

1. Go to this page and download the library: Download ymvas/ymsql 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/ */

    

ymvas / ymsql example snippets


use YMSQL\YMSQL;

// declare the database variables in ENV
$_ENV[  'DB_HOST'  ] = 'host';
$_ENV['DB_USERNAME'] = 'name';
$_ENV['DB_PASSWORD'] = 'pass';
$_ENV['DB_DATABASE'] = 'dtbs';

$v = new YMSQL( );
$query = $v->query(
   " SELECT * FROM Table T
     WHERE TRUE
    { AND T.name = :name } "
  ,[ 'name' => 'ymsql' ]
  , true  
);

// what query will return
/*
  $query
  "
  SELECT * FROM Table T
  WHERE TRUE
  AND T.name = 'ymsql'
  "
*/

$res = $v->get( $list = true );
//returns a standart class object

// if you want to return the mysqli instance run this instead
// $mysqli = $v->run( $list = true );


$values = [
  'name'     => 'ymsql',
  'getbasic' => true,
  'pass'     => 'secret'
]
 $db->query('select * from dbtable',array()); 
 $db->get( $list = false ); 
 $db->run(  $list = false ); /* retuns mysql instance */