Beispiel #1
0
}
///
$usersQ = $db->subQuery("u");
$usersQ->where("active", 1);
$usersQ->get("users");
$db->join($usersQ, "p.userId=u.id", "LEFT");
$products = $db->get("products p", null, "u.login, p.productName");
if ($products[2]['login'] != 'user1' || $products[2]['productName'] != 'product3') {
    echo "invalid join with subquery";
    exit;
}
if ($db->count != 5) {
    echo "invalid join with subquery count";
    exit;
}
$db->withTotalCount()->get('users', 1);
if ($db->totalCount != 3) {
    echo "error in totalCount";
    exit;
}
$result = $db->map('id')->ArrayBuilder()->getOne('users', 'id,login');
if (key($result) != 1 && $result[1] != 'user1') {
    echo 'map string=string failed';
    exit;
}
$result = $db->map('id')->ArrayBuilder()->getOne('users', 'id,login,createdAt');
if (key($result) != 1 && !is_array($result[1])) {
    echo 'map string=array failed';
    exit;
}
$result = $db->map('id')->ObjectBuilder()->getOne('users', 'id,login');