本文整理匯總了PHP中Brand::getDescription方法的典型用法代碼示例。如果您正苦於以下問題:PHP Brand::getDescription方法的具體用法?PHP Brand::getDescription怎麽用?PHP Brand::getDescription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Brand
的用法示例。
在下文中一共展示了Brand::getDescription方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
public function update(Brand $brand, $errors = array())
{
$id = $brand->getId();
$name = $this->db->quote($brand->getName());
$description = $this->db->quote($brand->getDescription());
$query = "UPDATE brand SET name = " . $name . ", description = " . $description . "WHERE id = " . $id;
$data = $this->db->exec($query);
if ($data) {
$id = $this->db->lastInsertId();
if ($id) {
try {
$brand = $this->findByid($id);
return $brand;
} catch (Exception $e) {
$errors[] = $e->getMessage();
return $errors;
}
} else {
throw new Exception('Last insert error');
}
} else {
throw new Exception('Update error');
}
}
示例2: create
/**
* @param $name
* @param $description
* @param array $errors
* @return object
* @throws Exception
*/
public function create($name, $description, $errors = array())
{
$category = new Brand($this->db);
try {
$category->setName($name);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
try {
$category->setDescription($description);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
if (count($errors) == 0) {
$name = $this->db->quote($category->getName());
$description = $this->db->quote($category->getDescription());
$query = "INSERT INTO category (name, description) VALUES(" . $name . ", " . $description . ")";
$data = $this->db->exec($query);
if ($data) {
$id = $this->db->lastInsertId();
if ($id) {
try {
$category = $this->findById($id);
return $category;
} catch (Exception $e) {
$errors[] = $e->getMessage();
return $errors;
}
} else {
throw new Exception('Last insert error');
}
} else {
throw new Exception('Insert error');
}
} else {
return $errors;
}
}