PHP code example of mg3lo / mysql-crud

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

    

mg3lo / mysql-crud example snippets


	composer 

	
	// Load library installed via composer
	re_once './Mg3lo/vendor/autoload.php'; 

	use Mg3lo\MySqlCrud;
	

	
	
	3lo\MySqlCrud;

	// connect to your database
	$crud = new MySqlCrud([
	  'username' => 'root',
	  'password' => '',
	  'database' => 'my_database'
	]);

	// do your magic
	$products = $crud->table('products')->get();
	

	composer 

	 
	  // Load library installed via composer
	  e_once APPPATH . 'third_party/Mg3lo/vendor/autoload.php';
		
	  use Mg3lo\MySqlCrud;
	

	 
	  Mg3lo\MySqlCrud;
		
	  class Crud extends CI_Controller {

		public function index()
		{
		  // connect to your mysql database
		  $crud = new MySqlCrud([
			'username' => 'root',
			'password' => '',
			'database' => 'my_database'
		  ]);
		  
		  // do your magic
		  $products = $crud->table('products')->get();
		}
	  }
	

	composer 

	// load the library if you did not install it via composer
	

	use Mg3lo\MySqlCrud;
	
	// connect to your mysql database
    $crud = new MySqlCrud([
	  'host' => env(DB_HOST),
	  'username' => env(DB_USERNAME),
	  'password' => env(DB_PASSWORD),
	  'database' => env(DB_DATABASE),
    ]);
	
	// do your magic
    $products = $crud->table('products')->get();
	

	composer 

	
	// Load library installed via composer
	re_once '.Your_Directory/Mg3lo/vendor/autoload.php'; 

	use Mg3lo\MySqlCrud;
	

	
	
	3lo\MySqlCrud;

	// connect to your database
	$crud = new MySqlCrud([
	  'username' => 'root',
	  'password' => '',
	  'database' => 'my_database'
	]);

	// do your magic
    $products = $crud->table('products')->get();