Simple way to read single record from MySQL

后端 未结 20 1300
一整个雨季
一整个雨季 2020-11-30 23:46

What\'s the best way with PHP to read a single record from a MySQL database? E.g.:

SELECT id FROM games

I was trying to find an answer in t

20条回答
  •  温柔的废话
    2020-12-01 00:24

    One more answer for object oriented style. Found this solution for me:

    $id = $dbh->query("SELECT id FROM mytable WHERE mycolumn = 'foo'")->fetch_object()->id;
    

    gives back just one id. Verify that your design ensures you got the right one.

提交回复
热议问题