tfdaoSingle对象使用技巧

发表于 2025-07-11 18:28:23
阅读 8

介绍

介绍


使用

准备

初始化一个tfdaoSingle对象

$tUser = (new user($this->tfphp))->getSG("user");

插入数据

$ret = $tUser->insert([
    ...
]);
$lastInsertId = $tUser->getLastInsertAutoIncrementValue();

更新数据

$ret = $tUser->update(["id"=>$lastInsertId], [
    ...
]);

$ret = $tUser->constraintUpdate([$lastInsertId], [
    ...
]);

$ret = $tUser->keyUpdate([$lastInsertId], [
    ...
]);

$ret = $tUser->sqlWhereUpdateAll("userId = @int", [$lastInsertId], [
    ...
]);

删除数据

$ret = $tUser->delete(["id"=>$lastInsertId]);

$ret = $tUser->constraintDelete([$lastInsertId]);

$ret = $tUser->keyDelete([$lastInsertId]);

$ret = $tUser->sqlWhereDeleteAll("userId = @int", [$lastInsertId]);

查询单行数据

$data = $tUser->select(["id"=>$lastInsertId]);

$data = $tUser->constraintSelect([$lastInsertId]);

$data = $tUser->keySelect([$lastInsertId]);

$data = $tUser->sqlWhereSelect("userId = @int", [$lastInsertId]);

查询多行数据

$data = $tUser->selectMany(["id"=>$lastInsertId], 0, 10);

$data = $tUser->constraintSelectMany([$lastInsertId], 0, 10);

$data = $tUser->keySelectMany([$lastInsertId], 0, 10);

$data = $tUser->sqlWhereSelectMany("userId = @int", [$lastInsertId], 0, 10);

查询全部数据

$data = $tUser->selectAll(["id"=>$lastInsertId]);

$data = $tUser->constraintSelectAll([$lastInsertId]);

$data = $tUser->keySelectAll([$lastInsertId]);

$data = $tUser->sqlWhereSelectAll("userId = @int", [$lastInsertId]);

待续。。。