当前位置: 首页>>代码示例>>PHP>>正文


PHP UserModel::setId方法代码示例

本文整理汇总了PHP中UserModel::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::setId方法的具体用法?PHP UserModel::setId怎么用?PHP UserModel::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserModel的用法示例。


在下文中一共展示了UserModel::setId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadBy

    /**
     * Load user by a particular field
     * @param  string $field    The field to find by
     * @param  string $value    The field value
     * @return UserModel
     */
    public static function loadBy($field, $value)
    {
        global $wpdb;

        $UserModel = new UserModel();
        switch ($field) {
            case 'id':
                $memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE user_id = %d AND status != 'deleted'", $value), ARRAY_A);
                break;
            case 'verification_code':
                $memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE verification_code = %s AND status != 'deleted'", $value), ARRAY_A);
                break;
            case 'reset_password_code':
                $memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE reset_password_code = %s AND status != 'deleted'", $value), ARRAY_A);
                break;
            case 'email_address':
                $memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE email_address = %s AND status != 'deleted'", $value), ARRAY_A);
                break;
        }

        if ($memberData) {
            $UserModel->setId($memberData['user_id']);
            $UserModel->populateFromArray($memberData);

            if ($UserModel->getStatus() == 'deleted') {
                return new UserModel();
            }
        }

        return $UserModel;
    }
开发者ID:jknowles94,项目名称:Work-examples,代码行数:37,代码来源:user.model.php

示例2: findById

 public function findById($id)
 {
     $data = $this->storage->findById($id);
     $user = new UserModel();
     $user->setId($data['id']);
     $user->setName($data['name']);
     $user->setEmail($data['email']);
     $user->setActive($data['active']);
     return $user;
 }
开发者ID:GabrielDeveloper,项目名称:designPatterns,代码行数:10,代码来源:UserRepository.php

示例3: fromObject

 public static function fromObject($o)
 {
     $user = new UserModel();
     $user->setId($o->id);
     $user->setEmail($o->email);
     $user->setPassword($o->password);
     $user->setName($o->name);
     $user->setSurname($o->surname);
     $user->setOrganisation($o->organisation);
     return $user;
 }
开发者ID:stefda,项目名称:decimill-web-frontend,代码行数:11,代码来源:UserModel.php

示例4: getSome

    /**
     * @param string $whereClause
     * @see ControllerBase::getSome()
     */
    public function getSome($whereClause = '1 = 1')
    {
        $sql = <<<SQL
SELECT id
     , username
     , password
     , psalt
     , created
     , updated
  FROM user
 WHERE {$whereClause}
 ORDER
    BY updated
SQL;
        $stmt = $this->_dbh->prepare($sql);
        if (!$stmt) {
            throw new ControllerException('Failed to prepare SELECT statement. (' . $this->_dbh->error . ') from this SQL: ' . $sql);
        }
        if (!$stmt->execute()) {
            throw new ControllerException('Failed to execute SELECT statement. (' . $this->_dbh->error . ')');
        }
        $id = $userName = $password = $psalt = $created = $updated = null;
        $stmt->bind_result($id, $userName, $password, $psalt, $created, $updated);
        $models = array();
        while ($stmt->fetch()) {
            $model = new UserModel();
            $model->setId($id);
            $model->setUserName($userName);
            $model->setPassword($password);
            $model->setPSalt($psalt);
            $model->setCreated($created);
            $model->setUpdated($updated);
            $models[] = $model;
        }
        return $models;
    }
开发者ID:kbcmdba,项目名称:pjs2,代码行数:40,代码来源:UserController.php

示例5: function

$app->get('/general/statistics', function () {
    $cra = new CesRestAPI();
    print $cra->getStatistics();
})->setName('general statistics');
// logout
$app->get('/general/backup', function () {
    $cra = new CesRestAPI();
    print $cra->saveBackup();
})->setName('general backup');
//user post (update)
$app->post('/user/:id', function ($id) use($app) {
    $body = $app->request()->getBody();
    parse_str($body, $data);
    //die(var_dump($data));
    $user = new UserModel();
    $user->setId($id);
    $user->setCesUid($data['ces_uid']);
    $user->setPassword($data['password']);
    $user->setFirstname($data['firstname']);
    $user->setSurname($data['surname']);
    $user->setOrgname($data['orgname']);
    $user->setAddress1($data['address1']);
    $user->setAddress2($data['address2']);
    $user->setAddress3($data['address3']);
    $user->setPostcode($data['postcode']);
    $user->setSubareaId($data['subareaId']);
    $user->setSubarea($data['subarea']);
    $user->setPhoneh($data['phoneh']);
    $user->setPhonew($data['phonew']);
    $user->setPhonef($data['phonef']);
    $user->setPhonem($data['phonem']);
开发者ID:jescacena,项目名称:cispAPI,代码行数:31,代码来源:index.php


注:本文中的UserModel::setId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。