dongsheng6056 2014-03-26 13:33
浏览 52
已采纳

PDO :: FETCH_OBJ php

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] => frank@frank.com [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!

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!

  • 写回答

2条回答 默认 最新

  • dpcj32769 2014-03-26 13:35
    关注

    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.

    Example:

    print_r($results[0]->email);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 VAE代码如何画混淆矩阵
  • ¥15 求遗传算法GAMS代码
  • ¥15 雄安新区高光谱数据集的下载网址打不开
  • ¥66 android运行时native和graphics内存详细信息获取
  • ¥100 求一个c#通过CH341读取数据的Demo,能够读取指定地址值的功能
  • ¥15 rk3566 Android11 USB摄像头 微信
  • ¥15 torch框架下的强化学习DQN训练奖励值浮动过低,希望指导如何调整
  • ¥35 西门子博图v16安装密钥提示CryptAcquireContext MS_DEF_PROV Error of containger opening
  • ¥15 mes系统扫码追溯功能
  • ¥40 selenium访问信用中国