PHP code example of uuur86 / ubdb

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

    

uuur86 / ubdb example snippets


$ubdb = new ubdb();
// For Selecting a language
$ubdb->lang('en');
// For Define db, table and columns
$ubdb->db('mydb', array(
                        'users'=>array(
                            'username',
                            'password',
                            'email',
                            'phone'
                        ),

                        'products'=>array(
                            'productname',
                            'productcode',
                            'title',
                            'description'
                        ),
                        'cart'=>array(
                            'productid',
                            'userid'
                        )   
                    )
                );


// add a row
$ubdb->add('cart', array('userid'=>'ugur'.$i));

// or

	// You can add multiple rows
	for($i=0;$i<10;$i++){
	$ubdb->add('cart', array('userid'=>'ugur'.$i));
	}
	
// If you defined all rows, you can save for writing new datas.
$ubdb->save();
      
 // For any simple query for getting datas
 // When runnig below code, will be same all getting datas
 // ? Symbol holding only one character, % symbol holding multiple character as place.
 $get1 = $ubdb->get("users", "username", array("ugur",'?','1') ); // matches such as ugur11
 $get2 = $ubdb->get("users", "username", array("ug",'%','1') );   // matches such as ugur11 or ugor21
 
 // Joining two data array on one intersect point
 $results = $ubdb->join(
			$get1,       // first array
                        $get2,       // second array
                        "username",  // first intersect point
                        "userid"     // secondary intersect point
                        );
 // Will return as an array which is username equals to userid
 

$ubdb->delete($table,$id);