本文整理汇总了PHP中AppModel::Create方法的典型用法代码示例。如果您正苦于以下问题:PHP AppModel::Create方法的具体用法?PHP AppModel::Create怎么用?PHP AppModel::Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppModel
的用法示例。
在下文中一共展示了AppModel::Create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
// Data
$this->data = $_POST;
// TODO clean up data for SQL here?
// View
$this->View = new AppView();
// Model
if ($this->has_model) {
// load Model class
if (Globe::Load(Url::$data['model'], 'model')) {
$this->Model = $this->{Url::$data['modelName']} = AppModel::Create(Url::$data['modelName']);
// reference for ease
}
}
}
示例2: signup
public function signup()
{
if ($this->data) {
if (!$this->data('email') || !$this->data('password')) {
Error::Set("Fields blank!", 'validation');
return false;
}
// create
$this->Model = AppModel::Create(CLASS_USER_MEMBER, $this->data);
// valid?
if ($this->Model->save()) {
$this->redirect('/users/login');
}
} else {
$this->assign(array('redirect_to' => null, 'email' => null));
}
}
示例3: Init
static function Init($name, $type = 'class', $show_errors = true)
{
if (self::Load($name, $type, $show_errors)) {
$class_name = AppInflector::classify($name, $type);
return $type == 'model' ? AppModel::Create($class_name) : new $class_name();
} else {
return new stdClass();
}
}
示例4: GetCurrent
/**
* This is basically the 'Login' function.
* It cycles through different possible locations for the user,
* lastly checking if a login is occurring.
*
* @return User object. FALSE on fail.
*/
static function GetCurrent()
{
// session?
if ($session = AppUser::GetSession()) {
if ($user = AppUser::FetchFromString($session)) {
return $user;
}
} elseif ($cookie = AppUser::GetCookie()) {
if ($user = AppUser::FetchFromString($cookie)) {
return $user;
}
} elseif (Url::GetRequest('check_data', false) && ($email = Url::GetRequest('email', false)) && ($password = Url::GetRequest('password', false))) {
// valid?
if (($user = AppUser::FetchUser($email)) && $user->validate($password)) {
return AppUser::SetCurrent($user);
} else {
Error::Set("Invalid Email and/or Password", 'validation');
}
}
// create Guest...
return AppModel::Create(AppUser::$levels[0]);
}
示例5: FindAllAssoc
static function FindAllAssoc($strClass, $extend = FALSE, $mxdWhere = NULL, $strIndexBy = 'id', $strOrderBy = null, $intLimit = 10000, $intOffset = 0)
{
if (!AppModel::_smartLoadModel($strClass)) {
return false;
}
$model = AppModel::Create($strClass);
// TODO replace by ::singleton
$strOrderBy = get_default($strOrderBy, $model->order_by);
// get collection
$collection = AppModel::FindAll($strClass, $extend, $mxdWhere, $strOrderBy, $intLimit, $intOffset);
// associate label
$output = array();
foreach ($collection as $key => $object) {
$output[$object->{$strIndexBy}] = $object;
}
return $output;
}