本文整理匯總了PHP中models\User::getId方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::getId方法的具體用法?PHP User::getId怎麽用?PHP User::getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::getId方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: save
public function save(User $user)
{
$query = "SELECT * FROM users WHERE username = ?";
$this->db->query($query, [$user->getUsername()]);
$result = $this->db->row();
if ($result) {
echo 'The username already taken!';
die;
}
$query = "\n INSERT INTO users (username, email, cash, roleId, password)\n VALUES (?, ?, ?, ?, ?)\n ";
$params = [$user->getUsername(), $user->getEmail(), floatval($user->getCash()), $user->getRole(), $user->getPassword()];
if ($user->getId()) {
$query = "UPDATE players SET username = ?, password = ? WHERE id = ?";
$params[] = $user->getId();
}
$this->db->query($query, $params);
return $this->db->rows() > 0;
}
示例2: setOwner
/**
* Declares an association between this object and a ChildUser object.
*
* @param ChildUser $v
* @return $this|\Models\Group The current object (for fluent API support)
* @throws PropelException
*/
public function setOwner(ChildUser $v = null)
{
if ($v === null) {
$this->setOwnerId(NULL);
} else {
$this->setOwnerId($v->getId());
}
$this->aOwner = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildUser object, it will not be re-added.
if ($v !== null) {
$v->addMyGroup($this);
}
return $this;
}
示例3: getId
public function getId()
{
$this->_load();
return parent::getId();
}
示例4: getId
/**
* {@inheritDoc}
*/
public function getId()
{
if ($this->__isInitialized__ === false) {
return (int) parent::getId();
}
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array());
return parent::getId();
}
示例5: prune
/**
* Exclude object from result
*
* @param ChildUser $user Object to remove from the list of results
*
* @return $this|ChildUserQuery The current query, for fluid interface
*/
public function prune($user = null)
{
if ($user) {
$this->addUsingAlias(UserTableMap::COL_ID, $user->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
示例6: filterByUser
/**
* Filter the query by a related \Models\User object
*
* @param \Models\User|ObjectCollection $user The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @throws \Propel\Runtime\Exception\PropelException
*
* @return ChildCategoryQuery The current query, for fluid interface
*/
public function filterByUser($user, $comparison = null)
{
if ($user instanceof \Models\User) {
return $this->addUsingAlias(CategoryTableMap::COL_USER_ID, $user->getId(), $comparison);
} elseif ($user instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this->addUsingAlias(CategoryTableMap::COL_USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByUser() only accepts arguments of type \\Models\\User or Collection');
}
}
示例7: saveSessionCookieForUser
/**
* Salva o cookie de autenticação
* @param \Models\User $user Objeto \Models\User do usuário logado
*/
public static function saveSessionCookieForUser(\Models\User $user)
{
$cookieData = ['id' => $user->getId(), 'token' => $user->getToken()];
// 2592000 = 60 * 60 * 24 * 30, ou seja, 30 dias em segundos
setcookie(AUTH_USER_COOKIE_NAME, serialize($cookieData), time() + 2592000);
}
示例8: filterByUser
/**
* Filter the query by a related \Models\User object
*
* @param \Models\User $user The related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @throws \Propel\Runtime\Exception\PropelException
*
* @return ChildSharedQuery The current query, for fluid interface
*/
public function filterByUser($user, $comparison = null)
{
if ($user instanceof \Models\User) {
return $this->addUsingAlias(SharedTableMap::COL_TO_TYPE, 'user', $comparison)->addUsingAlias(SharedTableMap::COL_TO_ID, $user->getId(), $comparison);
} else {
throw new PropelException('filterByUser() only accepts arguments of type \\Models\\User');
}
}
示例9: update
private static function update(User $model)
{
$db = Database::getInstance('app');
$query = "UPDATE users SET username= :username, email= :email, password= :password, role_id= :role_id, f_name= :f_name, l_name= :l_name, gender= :gender, date_of_birth= :date_of_birth, registered_at= :registered_at WHERE id = :id";
$result = $db->prepare($query);
$result->execute([':id' => $model->getId(), ':username' => $model->getUsername(), ':email' => $model->getEmail(), ':password' => $model->getPassword(), ':role_id' => $model->getRole_id(), ':f_name' => $model->getF_name(), ':l_name' => $model->getL_name(), ':gender' => $model->getGender(), ':date_of_birth' => $model->getDate_of_birth(), ':registered_at' => $model->getRegistered_at()]);
}
示例10: updateUser
public function updateUser(User $user)
{
$result = $this->db->prepare("\n\t\t\tUPDATE user\n\t\t\tSET money = ?,\n\t\t\t\tbanned = ?\n\t\t\tWHERE id = ?\n\t\t");
$result->execute([$user->getMoney(), $user->getBanned(), $user->getId()]);
}
示例11: startSession
/**
* ### Starts a session for the given user
*
* @param \Models\User $user
*/
private static function startSession($user)
{
$_SESSION['logged_in'] = 1;
$_SESSION['user'] = $user->getId();
}
示例12: update
private static function update(User $model)
{
$db = Database::getInstance('app');
$query = "UPDATE user SET username= :username, password= :password, registerDate= :registerDate, emailVerified= :emailVerified, email= :email, createdAt= :createdAt, updatedAt= :updatedAt WHERE id = :id";
$result = $db->prepare($query);
$result->execute([':id' => $model->getId(), ':username' => $model->getUsername(), ':password' => $model->getPassword(), ':registerDate' => $model->getRegisterDate(), ':emailVerified' => $model->getEmailVerified(), ':email' => $model->getEmail(), ':createdAt' => $model->getCreatedAt(), ':updatedAt' => $model->getUpdatedAt()]);
}
示例13: setOriginUser
/**
* Declares an association between this object and a ChildUser object.
*
* @param ChildUser $v
* @return $this|\Models\Notification The current object (for fluent API support)
* @throws PropelException
*/
public function setOriginUser(ChildUser $v = null)
{
if ($v === null) {
$this->setOriginType(null);
} else {
$this->setOriginType('user');
}
if ($v === null) {
$this->setOriginId(NULL);
} else {
$this->setOriginId($v->getId());
}
$this->aOriginUser = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildUser object, it will not be re-added.
if ($v !== null) {
$v->addNotificationRelatedByOriginTypeOriginId($this);
}
return $this;
}