Read one column from one row from a MySQL database

前端 未结 8 1965
没有蜡笔的小新
没有蜡笔的小新 2021-01-15 03:30

Is there a quick and dirty way to get the value of one column from one row? Right now I use something like this:

$result = mysql_query(\"SELECT value FROM ta         


        
8条回答
  •  时光取名叫无心
    2021-01-15 04:15

    What you should look for is an encapsulation mecanism. For example you could create a classe User that would correspond to a rows of SQL table "user". Then you could get his id just with a single line:

    $user->getID();
    

    You could also create a class that would aggregate all the user and then use something like this:

    $collection->getUserID("3435563");
    

    But really there isn't a simpler way to do it in my knowledge.

提交回复
热议问题