本文整理匯總了PHP中Subject::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP Subject::add方法的具體用法?PHP Subject::add怎麽用?PHP Subject::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Subject
的用法示例。
在下文中一共展示了Subject::add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doAddSubject
public function doAddSubject()
{
$subject = new StdClass();
$fields = array('name' => Data::STR);
foreach ($fields as $field => $dataType) {
$subject->{$field} = Data::get($field, '', $dataType);
}
$a = (object) array('success' => false, 'message' => '');
if (Subject::add($subject)) {
$a->message = 'Урок успешно добавлен!';
$a->success = true;
} else {
$a->message = 'Ошибка при добавлении урока';
}
return $a;
}
示例2: subject
public static function subject($type, $data)
{
require_once 'subject.class.php';
$class = new Subject();
$status = false;
$class->setData($data);
switch ($type) {
case 'add':
$status = $class->add();
break;
case 'update':
$status = $class->update();
break;
case 'delete':
$status = $class->delete();
break;
case 'getsingle':
$status = $class->getsingle();
break;
case 'getpage':
$status = $class->getpage();
break;
case 'search':
$status = $class->search();
break;
default:
break;
}
if ($status) {
wp_send_json_success($status);
} else {
wp_send_json_error($class->error);
}
}