Example #1
0
 public function searchAction()
 {
     $this->setTitle('Cautare Produse - Auto Parts Supply');
     $query = isset($_GET['query']) ? $_GET['query'] : null;
     $products = array();
     $error = '';
     if ($query) {
         $sql = 'SELECT * FROM ' . ProductEntity::getTable() . " WHERE name LIKE '%" . $query . "%'";
         $statement = Project::getDB()->prepare($sql);
         if ($statement->execute()) {
             $products = $statement->fetchAll(\PDO::FETCH_CLASS, 'App\\Entity\\ProductEntity');
         }
         if (count($products) == 0) {
             $error = 'Nu sunt produse pentru criterile cautarii.';
         }
     } else {
         $error = 'Parametri cautarii nu sunt corecti.';
     }
     $this->renderTemplate('product/search.php', array('products' => $products, 'error' => $error));
 }
Example #2
0
 public function deleteMultipleById($entityClassName, array $ids)
 {
     $ids = implode(', ', $ids);
     $sql = 'DELETE FROM ' . $this->getTable($entityClassName) . ' WHERE id in (' . $ids . ')';
     $db = Project::getDB();
     $stm = $db->prepare($sql);
     if ($stm->execute()) {
         return true;
     }
     return false;
 }