本文整理汇总了PHP中Network::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Network::model方法的具体用法?PHP Network::model怎么用?PHP Network::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the primary key value. Defaults to null, meaning using the 'id' GET variable
*/
public function loadModel()
{
if ($this->_nw === null) {
if ($id !== isset($_GET['id'])) {
$this->_nw = Network::model()->findByPk($_GET['id']);
}
if ($this->_nw === null || $this->_nw->userId != Yii::app()->user->id) {
throw new CHttpException(404, 'The requested network does not exist.');
}
}
return $this->_nw;
}
示例2: authenticate
public function authenticate($uloginModel = null)
{
$criteria = new CDbCriteria();
$criteria->condition = 'identity=:identity AND network=:network';
$criteria->params = array(':identity' => $uloginModel->identity, ':network' => $uloginModel->network);
$userNetwork = Network::model()->find($criteria);
if (null !== $userNetwork) {
$user = $userNetwork->user;
$this->id = $user->id;
$this->name = $user->email;
} else {
$user = new User();
$user->email = $uloginModel->email;
$user->firstName = $uloginModel->first_name;
$user->lastName = $uloginModel->last_name;
$user->sex = $uloginModel->sex;
$user->phone = $uloginModel->phone;
$user->bDate = $this->convertDate($uloginModel->bdate);
$user->city = $uloginModel->city;
$user->country = $uloginModel->country;
$user->ava = $uloginModel->photo;
$user->ava_full = $uloginModel->photo_big;
$user->activated = true;
if (!$user->save()) {
return false;
}
$nw = new Network();
$nw->identity = $uloginModel->identity;
$nw->network = $uloginModel->network;
$nw->userId = $user->id;
$nw->save();
$this->id = $user->id;
$this->name = $user->username;
}
$this->isAuthenticated = true;
return true;
}