PHP code example of offworks / overnight

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

    

offworks / overnight example snippets


$user = $db->from('user')
        ->select('name, email, birthdate')
        ->where('user_id = ?', array($userId))
        ->execute()->first();

$tickets = $db->from('ticket')
           ->where('available = ? AND used = ?', array(1, 0))
           ->where('expiry_date < ?', array('2020-10-10'))
           ->andWhere('seat_type = ?', array('single'))
           ->orWhere('master_ticket = ?', array(1))
           ->execute();

// will execute something like
SELECT * FROM ticket WHERE available = 1 AND used = 0 AND expiry_date < '2020-10-10' AND seat_type = 'single'

$users = $db->from('book')
        ->innerJoin('author ON author.author_id = book.author_id AND author.is_alive = ?', array(1))
        ->execute()->all();

$students = $db->from('student')
            ->where('is_alive = ?', array(1))
            ->orderBy('last_seen DESC')
            ->execute()->all();

$userId = $db->insert('user')->values($values)->execute()->id();

$db->update('book')
->where('book_id = ?', array($bookId))
->set(array('title' => 'the lost marble - first edition'))
->execute();

$db->delete('author')
->where('author_id = ?', array($authorId))
->execute();

from(string $table) or table(string $table)
select(string|array $columns)
where(string $condition, array $values = array())
orWhere(string $condition, array $values = array())
orderBy(string $orderBy)
groupBy(string $groupBy)
innerJoin(string $condition, array $values = array())
leftJoin(string $condition, array $values = array())
rightJoin(string $condition, array $values = array())
limit(int $limit, int $offset = null)
having(string $condition, array $values = array())
execute()->all()
execute()->first()

insert(string $table, array $values = array())
values(array $values)
execute()->id()

update(string $table)
set(array $data)
where(string $condition, array $values = array())
orWhere(string $condition, array $values = array())