PHP code example of jmajors / jaysqlwrap

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

    

jmajors / jaysqlwrap example snippets




$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();

$db = new Jaywrap\Jaywrap();

$data = array('username' => 'jasonmajors', 'password' => 'somehashedpassword', 'age' => 28, 'language' => 'php');
$success = $db->insert('users', $data);

$results = $db->select('sometable');

print_r($results);

/*
 *	Array ( 
 *		[0] => Array ( 
 *				[columnX] => someValue 
 *				[0] => someValue 
 * 				[columnY] => someOtherValue
 *				[1] => someOtherValue
 *		) 
 *		[1] => Array (
 *			 	[columnX] => someOtherValueTwo 
 * 			 	[0] => someOtherValueTwo
 *			 	[columnY] => someOtherValueThree
 *			 	[1] => someOtherValueThree
 * 		) 
 *	)
 */

$conditions = array('username' => 'jasonmajors', 'language' => 'php');
$results = $db->select('users', $conditions);

$conditions = array('username' => array('jasonmajors', 'johndoe', 'janedoe'));
$results = $db->select('table', $conditions);

$updates = array('language' => 'Python');
$conditions = array('username' => 'jasonmajors');
$success = $db->update('users', $updates, $conditions);

$delete = array('username' => 'jasonmajors');
$success = $db->delete('users', $updates, $conditions);
sql
SELECT * FROM table WHERE username = 'jasonmajors' AND language = 'php';