本文整理汇总了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;
}
}