1. Go to this page and download the library: Download octa-php/octa-pdo 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/ */
$db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4') AS amount_paid', FALSE);
$query = $db->get('mytable');
$db->where('name !=', $name);
$db->where('id <', $id);
// Produces: WHERE name != 'Joe' AND id < 45
$array = array('name' => $name, 'title' => $title, 'status' => $status);
$db->where($array);
// Produces: WHERE name = 'Joe' AND title = 'boss' AND status = 'active'
$where = "name='Joe' AND status='boss' OR status='active'";
$db->where($where);
$names = array('Frank', 'Todd', 'James');
$db->or_where_in('username', $names);
// Produces: OR username IN ('Frank', 'Todd', 'James')
$db->like('title', 'match', 'before');
// Produces: WHERE title LIKE '%match'
$db->like('title', 'match', 'after');
// Produces: WHERE title LIKE 'match%'
$db->like('title', 'match', 'both');
// Produces: WHERE title LIKE '%match%'
$array = array('title' => $match, 'page1' => $match, 'page2' => $match);
$db->like($array);
// WHERE title LIKE '%match%' AND page1 LIKE '%match%' AND page2 LIKE '%match%'
$db->like('title', 'match');
$db->or_like('body', $match);
// WHERE title LIKE '%match%' OR body LIKE '%match%'
$db->like('title', 'match');
$db->or_not_like('body', 'match');
// WHERE title LIKE '%match% OR body NOT LIKE '%match%'
$data = array(
'title' => $title,
'name' => $name,
'date' => $date
);
$db->where('id', $id);
$db->update('mytable', $data);
// Produces:
// UPDATE mytable
// SET title = '{$title}', name = '{$name}', date = '{$date}'
// WHERE id = $id
/*
class Myclass {
var $title = 'My Title';
var $content = 'My Content';
var $date = 'My Date';
}
*/
$object = new Myclass;
$db->where('id', $id);
$db->update('mytable', $object);
// Produces:
// UPDATE mytable
// SET title = '{$title}', name = '{$name}', date = '{$date}'
// WHERE id = $id