简体   繁体   English

Phalcon模型不接受变量

[英]Phalcon Model not accepting variable

I have a trouble when i try to verify if a user exists in the database. 我尝试验证数据库中是否存在用户时遇到麻烦。

$login = $this->cookies->get('login');
$loggedinas = $login->getValue();
$user = Users::findFirstByUsername($loggedinas)

This returns: 返回:

PHP Notice:  Trying to get property of non-object in /public_html/app/views/charactersheets/create.phtml on line 27, referer: localhost/charactersheets

However if i use this: 但是,如果我使用此:

$user = Users::findFirstByUsername("pentacore")

it works, and i've checked so that the cookie contains the right username with var_dump($loggedinas) (returns string(32) "pentacore", thank you silkfire) which returned pentacore so... what could be the problem? 它有效,并且我已经检查过cookie是否包含正确的用户名以及var_dump($ loggedinas)(返回string(32)“ pentacore”,谢谢Silkfire),它返回了pentacore,所以...可能是什么问题?

From Phalcon @ Phalcon Framework Forum: 来自Phalcon @ Phalcon框架论坛:

It could be that cookie's decryption adds extra trailing spaces so you have to probably do: Cookie的解密可能会添加额外的尾随空格,因此您可能必须这样做:

$login = $this->cookies->get('login');
$loggedinas = trim($login->getValue());
$user = Users::findFirstByUsername($loggedinas)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM