function get_examples($con, $args) { $examples = array(); if (isset($args["eid"])) { $eid = $args["eid"]; $sql = $con->prepare("SELECT section_id,ename,`order` FROM example WHERE eid=?"); $sql->bind_param("i", $eid); $sql->bind_result($section_id, $ename, $order); $sql->execute(); $sql->fetch(); $sql->close(); if (isset($section_id) && isset($ename) && isset($order)) { $tmp = new Example(); $tmp->populate($eid, $section_id, $ename, $order); $examples[] = $tmp->expose(); } } else { if (isset($args["ename"])) { $ename = $args["ename"]; $sql = $con->prepare("SELECT eid,section_id,`order` FROM example WHERE ename=?"); $sql->bind_param("s", $ename); $sql->bind_result($eid, $section_id, $order); $sql->execute(); while ($sql->fetch()) { if (isset($eid) && isset($section_id) && isset($order)) { $tmp = new Example(); $tmp->populate($eid, $section_id, $ename, $order); $examples[] = $tmp->expose(); } } $sql->close(); } else { $sql = $con->prepare("SELECT eid,ename,section_id,`order` FROM example"); $sql->bind_result($eid, $ename, $section_id, $order); $sql->execute(); while ($sql->fetch()) { if (isset($eid) && isset($ename) && isset($section_id) && isset($order)) { $tmp = new Example(); $tmp->populate($eid, $section_id, $ename, $order); $examples[] = $tmp->expose(); } } $sql->close(); } } return $examples; }