What We Do
We provide top quality services and best solutions based on your requirements and needs.
Share

How to change SQL Query to MXAPI

Example of basic  and advance query.

1. BASIC

SQL  :  Select * from rm_res_new where room = $id;

MXAPI :


$programObj = $_mxPub->factory("rm_res_new", MX_OBJECT_PROGRAM);

$criteria = array('room' => $id);

$articleObj = $programObj->getArticles($criteria);


2. ADVANCE

a)    Query “LIKE”

SQL  :  Select * from rm_res_new where submit_by LIKE '%'.$staffID.'%';

MXAPI :


$programObj = $_mxPub->factory("rm_res_new", MX_OBJECT_PROGRAM);

$criteria = array('submit_by' => array('%'.$staffID.'%', 'LIKE'));

$articleObj = $programObj->getArticles($criteria);


b)    Query for operator  “<=” OR “>=”

SQL  :  Select * from rm_res_new where flag_withdraw <= $flag_withdraw;

MXAPI :


$programObj = $_mxPub->factory("rm_res_new", MX_OBJECT_PROGRAM);

$criteria = array('flag_withdraw' => array($flag_withdraw, '<='));

$articleObj = $programObj->getArticles($criteria);


c)    Query “AND”

SQL  :  Select * from rm_res_new where floor =$pg AND room = $id;

MXAPI :


$programObj = $_mxPub->factory("rm_res_new", MX_OBJECT_PROGRAM);

$criteria = array('floor' => $pg, 'room' => $id);

$articleObj = $programObj->getArticles($criteria);



d)    Query “OR”

SQL  :  Select * from rm_res_new where host_empid = ‘$empid’ OR submit_by LIKE  ‘%‘.$empid.’%‘  OR attendee_int LIKE ‘%‘.$empid.’%‘ ;

MXAPI :


$programObj = $_mxPub->factory("rm_res_new", MX_OBJECT_PROGRAM);

$criteria = array('(OR)01' => array('host_empid' => $empid,  'submit_by' => array( ‘%’.$empid.'%', 'LIKE'),'attendee_int' => array( $empid, 'LIKE')));

$articleObj = $programObj->getArticles($criteria); 



e)    Query “OR + AND”

SQL  : Select * from rm_res_new where ((timestart >= ‘$time_start’ AND time start >= ‘$time_end’) OR(timeend>=‘$time_start’ AND timeend >= ‘$time_end));

MXAPI :


$programObj = $_mxPub->factory("rm_res_new", MX_OBJECT_PROGRAM);

$criteria = array('(OR)01' => array( 'timestart' => array( array($time_start, '>=', 'AND'), array($time_end, '<=', 'AND')) , '(OR)02' =>  array('timeend' => array(array($time_start, '>=', 'AND'), array($time_end, '<=', 'AND')))), 'orderby' => "<id" );

$articleObj = $programObj->getArticles($criteria);








MXAE Release News

MXAE 2.7.5 Released
We would like to announce the immediate availability of MXAE 2.7.5. This release focuses on...




Tips & Tricks

How to change SQL Query to MXAPI
SQL  :  Select * from...




MXAE Free Hosting

We are offering FREE hosting on MXAE platform with no string attached. You can use it as a development or demo hosting for your company. You can also use it to build your own website or host your client website.