PDO::FETCH_OBJ php

后端 未结 2 390
自闭症患者
自闭症患者 2021-01-26 07:16

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] =>         


        
相关标签:
2条回答
  • 2021-01-26 07:56

    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);
    
    0 讨论(0)
  • 2021-01-26 08:02

    You should use something like the following:

    foreach ($results as $row) {
            print_r($row->email);
    }
    

    If you expect to have just one row returned, it is always a good idea to check that. You can use count() with your $results variable like this:

    if (count($results)==1) {
          print_r($results[0]->email);
    }
    
    0 讨论(0)
提交回复
热议问题