上一篇《替換方法:Replace API-Medoo使用指南》中介紹瞭如何使用Medoo的Replace方法把數據庫中的舊數據替換成新的,本篇將教你使用Get方法來取得數據庫中的單條記錄。php
取得方法:Gethtml
取得數據庫中的單條記錄。數據庫
get($table, $columns, $where) //table [string]: 表名 //columns [string/array]: 將要獲取的數據的目標字段 //where (可選) [array]:WHERE子句篩選記錄
返回值: [string/array]:返回所設定的字段的數據函數
提示:這個函數只能獲取取得一條記錄。
post
$database = new medoo("my_database"); $email = $database->get("account", "email", [ "user_id" => 1234 ]); // $email = "foo@bar.com" $profile = $database->get("account", [ "email", "gender", "location" ], [ "user_id" => 1234 ]); // $profile = array( // "email" => "foo@bar.com", // "gender" => "female", // "location" => "earth" // )
Medoo版本: 0.9.1.1 spa
原文標題: 取得方法:Get API-Medoo使用指南 .net
原文連接: http://loiy.net/post/591.html code