PHP code example of sharpedge / cruder

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

    

sharpedge / cruder example snippets


  use Cruder\Sharp\SharpCrud as Cruder;
  $cruder = Cruder::getInstance('localhost', 'root', '', 'employees');
  $cruder->table('employees');
  $result = $cruder->getAll();

  use Cruder\Sharp\SharpCrud as Cruder;
  $cruder = Cruder::getInstance('localhost', 'root', '', 'employees');
  $select = array('emp_no', 'dept_no');
  $cruder->table('employees');
  $cruder->select($select);
 
  $result = $cruder->getAll();

  use Cruder\Sharp\SharpCrud as Cruder;
  $cruder = Cruder::getInstance('localhost', 'root', '', 'employees');
  $cruder->table('employees');
  $cruder->limit(50);
  $result = $cruder->getAll();

  use Cruder\Sharp\SharpCrud as Cruder;
  $cruder = Cruder::getInstance('localhost', 'root', '', 'employees');
  $cruder->table('employees');
  $cruder->offset(1);
  $cruder->limit(50);
  $result = $cruder->getAll();

  use Cruder\Sharp\SharpCrud as Cruder;
  $cruder = Cruder::getInstance('localhost', 'root', '', 'employees');
  $query = "SELECT * FROM table_name";
  $result = $cruder->raw($query);

  use Cruder\Sharp\SharpCrud as Cruder;
  $cruder = Cruder::getInstance('localhost', 'root', '', 'employees');
  //WHERE has to be an array
  $cruder->table('employees')->where(array('emp_no', '=', 500000));
  $result = $cruder->getAll();

  use Cruder\Sharp\SharpCrud as Cruder;
  $cruder = Cruder::getInstance('localhost', 'root', '', 'employees');
  $cruder->table('employees');
  $insert = array('emp_no' => '500000', 'birth_date' => '1992-01-21', 'first_name'=> "husnain", "last_name" => 'ahmed', 'gender' => 'M', 'hire_date' => '2001-04-02');
  $insert_return = $cruder->insert($insert); // it will return the inserted ID