PHP code example of webfiori / ph-mysql

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

    

webfiori / ph-mysql example snippets

 php
 $query->createTable();
 // display the constructed query.
 print_r('<pre>'.$query.'</pre>);
 
 php
$query->updateRecord([
  'username'=>'MySuperHeroIsYou',
  'password'=>'f5d44b6d4a7d91821d602d03c096280e86888fa16cf9c27c540bbc2fd4e73932',
],
[
  'user-id'=>99
]);
 php
$query->deleteRecord([
  'user-id'=>99
]);
 php
use phMysql\MySQLLink;

$conn = new MySQLLink('localhost', 'root', '123456');

if($conn->getErrorCode() != 0) {
  //connection error. Show error message
  echo $conn->getErrorMessage();
} else {
  //connected. Select database now.
  
  if($conn->setDB('my_database')) {
  
    //connected. Now can execute quires.
  
  } else {
    //unable to set database
    echo $conn->getErrorMessage();
  }
}
 php
$query->insertRecord([
  'user-id'=>99,
  'username'=>'MySuperHeroIsYou',
  'password'=>'f5d44b6d4a7d91821d602d03c096280e86888fa16cf9c27c540bbc2fd4e73932',
  'created-on'=>date('Y-m-d H:i:s')
]);
if($conn->executeQuery($query)) {
  //query executed without errors
} else {
  //something went wrong. Show error message
  echo $conn->getErrorMessage();
}