function searchForItems($searchBox) { $mc = MysqlConnectionHandler::getInstance(); $conn = $mc->getDbConn(); if (!$conn) { echo "OMG"; } else { $statement = $conn->prepare("select * from Item where code LIKE CONCAT('%', ?, '%') OR name LIKE CONCAT('%', ?, '%') or id =?"); if ($statement) { $id = $_POST['updateFormSearchInput']; if (is_numeric($id)) { $statement->bind_param("ssi", $searchBox, $searchBox, intval($id)); } else { $id = 0; $statement->bind_param("ssi", $searchBox, $searchBox, $id); } $statement->execute(); $return = $statement->get_result(); $statement->close(); self::$resultsFromSearch = array(); while ($item = $return->fetch_row()) { $itemret = new Auto(); $itemret->setId($item[0]); $itemret->setName($item[1]); $itemret->setCode($item[2]); // var_dump($itemret); array_push(self::$resultsFromSearch, $itemret); } return True; } else { return false; } } }
<?php header('Content-type: text/plain'); require_once dirname(__FILE__) . '/../rest_controladoras/ItemControllerRest.php'; $ic = ItemControllerRest::getInstance(); foreach ($_GET as $key => $value) { $item = $ic->getItemById($value, $key); echo $item; return; } $items = $ic->getAllItems(); echo $items;