PHP code example of kroyxlab / datbazo

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

    

kroyxlab / datbazo example snippets



use kroyxlab\datbazo\DatBazo as DatBazo;


use kroyxlab\datbazo\DatBazo as DatBazo;

// instantiate the DatBazo class
$productos = new DatBazo;

// Create an SQL statement using the methods of the KLPdo class
$products->select(['products'=>'name, price'])
          ->where(['price'=>['>=', 12.5]])
          ->order('price')
          ->execute();

// Set the type of fetch you want.
$products->fetch('assoc');

// Use the Method -> render (); to output and format the result of the sql query
$products->render(function($product){

  return "<p>The name of the product is {$product['name']} and the price is {$product['price']}</p>";

});

// Or use a foreach loop using the fetch method

foreach($products->fecth('obj') as $product){
  echo "<p>The name of the product is $product->name and the price is $product->price</p>"
}