Simple way to read single record from MySQL

后端 未结 20 1354
一整个雨季
一整个雨季 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:41

    'Best way' aside some usual ways of retrieving a single record from the database with PHP go like that:

    with mysqli

    $sql = "SELECT id, name, producer FROM games WHERE user_id = 1";
    $result = $db->query($sql);
    $row = $result->fetch_row();
    

    with Zend Framework

    //Inside the table class

    $select = $this->select()->where('user_id = ?', 1);  
    $row = $this->fetchRow($select);
    

提交回复
热议问题