Ejemplo n.º 1
0
 function deleteImg($id)
 {
     $item = parent::find($id);
     if ($item->getImg() == "") {
         return;
     }
     $query = $this->pdo->prepare("UPDATE news SET img = '' WHERE id = ?");
     $result = $query->execute(array($id));
     if (!$result) {
         throw new \Exception("Ошибка базы данных. Запрос на обновление поля изображения не прошел");
     }
     unlink("../content_imgs/news_logos/" . $item->getImg() . ".jpg");
 }
Ejemplo n.º 2
0
 function testShouldFindByCategoryAndAttribute()
 {
     $product_mapper = new DataMapper($this->db);
     // should find
     $product_mapper->save(new Product(array('sku' => 'foo1', 'categories' => [1], 'attributes' => ['color' => 'red'])));
     // should not find
     $product_mapper->save(new Product(array('sku' => 'foo2', 'categories' => [2], 'attributes' => ['color' => 'red'])));
     // should not find
     $product_mapper->save(new Product(array('sku' => 'foo3', 'categories' => [1], 'attributes' => ['color' => 'blue'])));
     $products = $product_mapper->find(array('category' => 1, 'attributes' => ['color' => 'red']));
     $this->assertEquals(1, count($products), 'should find by attribute & category');
 }