本文整理汇总了PHP中Company::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP Company::findById方法的具体用法?PHP Company::findById怎么用?PHP Company::findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Company
的用法示例。
在下文中一共展示了Company::findById方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCompany
public function setCompany($value)
{
if ($value instanceof Company) {
$this->_orm->company_id = $value->id;
return true;
}
$company = Company::findById($value);
if ($company) {
$this->_orm->company_id = $value;
return true;
}
throw new Exception("Company does not exist");
}
示例2: get
public static function get()
{
return function ($req, $res) {
$res->header('Content-Type', 'application/json');
$model = Company::findById($req->id);
if ($model) {
if ($req->method('post')) {
$data = json_decode(file_get_contents("php://input"));
$model->name = $data->name;
$model->description = $data->description;
$model->save();
echo $model;
} elseif ($req->method('delete')) {
$model->delete();
$res->code(200);
} else {
echo $model;
}
} else {
$res->code(404);
}
};
}
示例3:
<?php
require "../company.php";
$co = Company::findById(3);
echo $co->products[1]->as_joined_json();
示例4: isset
<?php
$id = isset($vars[1]) ? $vars[1] : null;
$object = Company::findById($id);
$error_flag = false;
if ($object) {
if ($object->delete()) {
Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'Record deleted', 'zh' => '记录删除成功'))));
} else {
$error_flag = true;
}
} else {
$error_flag = true;
}
if ($error_flag) {
Message::register(new Message(Message::DANGER, i18n(array('en' => 'Record deletion failed', 'zh' => '记录删除失败'))));
}
HTML::forwardBackToReferer();
示例5: getCompany
public function getCompany()
{
return Company::findById($this->getCompanyId());
}