版本: v2.6.0
get
从数据表中获取单条记录。
get($table, $columns, $where)
get($table, $join, $columns, $where)
返回值
[mixed] 返回首条匹配记录;如果只查询单列,则返回标量值,否则返回关联数组。
$email = $database->get("account", "email", [
"user_id" => 1234
]);
// 示例结果:
// "foo@bar.com"
$profile = $database->get("account", [
"email",
"gender",
"location"
], [
"user_id" => 1234
]);
// 示例结果:
// array(
// "email" => "foo@bar.com",
// "gender" => "female",
// "location" => "earth"
// )
$data = $database->get("post", [
"[>]account" => "user_id"
], [
"post.content",
"account.user_name",
"account.location"
], [
"ORDER" => "post.rate"
]);
// 示例结果:
// array(
// "content" => "A new day",
// "user_name" => "foo",
// "location" => "earth"
// )