PHP code example of yudhigule / sql-gen

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

    

yudhigule / sql-gen example snippets


 
 LGen\SQLGenerator as SQL;
 $sqlGenerator = new SQL("table_name");
 
 
 
 Generator as SQL;

 $sqlGenerator = new SQL("members");
 $insertParams = [
	 "id"=>1,
	 "name"=>'yudhigule',
	 'email'=>'[email protected]',
	 'age'=>24
 ];
 $sqlInsert = $sqlGenerator->create($insertParams)->sql();
 $sqlUpdate = $sqlGenerator->update($insertParams)
				 ->where("name","yudhigule")
				 ->where("age",24,'>')
				 ->sql();
 $sqlSelect = $sqlGenerator->select(['id','name'])->where('id',1)->sql();
 $sqlDelete = $sqlGenerator->delete()->where('id',1)->sql();

printf("%s \n",$sqlInsert);
printf("%s \n",$sqlUpdate);
printf("%s \n",$sqlSelect);
printf("%s \n",$sqlDelete);