<?php
namespace factory;

class Clients
{
  static public function get_all()
  {
    global $mdb;
    return $mdb -> select( 'clients', '*', [ 'ORDER' => [ 'name' => 'ASC' ] ] );
  }

  static public function get( $id )
  {
    global $mdb;
    return $mdb -> get( 'clients', '*', [ 'id' => $id ] );
  }

  static public function create( $data )
  {
    global $mdb;
    $mdb -> insert( 'clients', $data );
    return $mdb -> id();
  }

  static public function update( $id, $data )
  {
    global $mdb;
    return $mdb -> update( 'clients', $data, [ 'id' => $id ] );
  }

  static public function delete( $id )
  {
    global $mdb;
    return $mdb -> delete( 'clients', [ 'id' => $id ] );
  }
}
