<?php
//example of advanced query builder usage
require_once 'Mysql.php';
require_once 'ExampleObject.php';
Mysql::Init('localhost', 'username', 'password', 'database');
$ex1 = new ExampleObject(array('field1`!=' => '1', 'field2`>' => '123'));
//the array key is by default the fieldname and vaue is the value in database
//but since searching by = does not cover all cases, it is possible to add additional conditions such as ( >, >=, !=, <, <= ) by adding separator ` between the fieldname and the operator
//right now in variable $ex1 there should be an object that has field1 not equal to 1 and field2 greater than 123
//it is also possible to specify AND/OR queries like: array('AND' => array('field1' => 1, 'field2' => 3, 'OR' => array('field3' => 1, 'field4' => 1))) and it would end up in a query
// WHERE field1 = 1 AND field2 = 3 AND (field3 = 1 OR field4 = 1)
// To reverse the operation prepen AND/OR with ! to get !(smth OR smth2)
?>
|