本文介绍了PDO :: FETCH_OBJ php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PDO :: FETCH_OBJ->返回一个匿名对象,该对象的属性名称与结果集中返回的列名称相对应.例如:
PDO::FETCH_OBJ -> Returns an anonymous object with property names that correspond to the column names returned in your result set.For example:
Array ( [0] => stdClass Object ( [id] => 3 [email] => [email protected] [password] => password [salt] => salt [devices] => 1 [accounttype] => 1 [accountcreated] => 2014-03-26 [confirmed] => 1 [confirmcode] => 0 [logindate] => 2014-03-26 ) )
如何获取电子邮件值???????以下是我到目前为止的情况
How do I get the email value??????? Below is what i have so far
$_db = DB::getInstance();
$_db = $_db->query('SELECT * FROM users WHERE email = ? AND password = ? ', array($email, $pass));
$results = $_db->results();
print_r($results);
print_r($results->email); <<<<<<<<<<<--- does not work!
请帮助24小时....我知道它很简单,因为我之前已经做过...似乎无法记得找到任何引用代码!
PLEASE HELP been at this for 24hours.... I know its simple because I have done it before... just cant seem to remember of find any referencing code!
推荐答案
您可以在粘贴内容中看到$ results是对象数组,因此您需要指定数组中的哪个项目才能获得正确的电子邮件结果
You can see in what you pasted that $results is an array of objects, so you need to specify which item in the array to get a proper result for email.
示例:
print_r($results[0]->email);
这篇关于PDO :: FETCH_OBJ php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!