本文整理匯總了PHP中DataMapper::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataMapper::find方法的具體用法?PHP DataMapper::find怎麽用?PHP DataMapper::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DataMapper
的用法示例。
在下文中一共展示了DataMapper::find方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: deleteImg
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");
}
示例2: testShouldFindByCategoryAndAttribute
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');
}