While implementing something similar I added my own insert implementation because I wasn't satisfied with yours. The point is that it feels unnatural to pass $values and $parameters separately. I'm aware it is more flexible since you can use NOW(), subqueries and what not but in reality I wouldn't mind using the QueryBuilder directly for such cases. I see the insert method as just a simple helper so I wanted API like this:
public function insert(string $table, array $values): PromiseInterface
{
$queryBuilder = $this->createQueryBuilder();
$queryBuilder->insert($table);
foreach ($values as $column => $value) {
$queryBuilder
->setValue($column, ':' . $column)
->setParameter($column, $value);
}
return $this->query($queryBuilder);
}
It might be nice to add an update and delete methods with similar API:
public function update(string $table, array $values, array $where): PromiseInterface;
public function delete(string $table, array $where): PromiseInterface;
Note: I don't really care if you use this or not since I'm not using Drift directly. It's just a suggestion. Use it or close it as you see fit. ;-)
Btw. this is incorrect since it's a delete method.
While implementing something similar I added my own insert implementation because I wasn't satisfied with yours. The point is that it feels unnatural to pass
$values
and$parameters
separately. I'm aware it is more flexible since you can useNOW()
, subqueries and what not but in reality I wouldn't mind using the QueryBuilder directly for such cases. I see the insert method as just a simple helper so I wanted API like this:It can be implemented quite easily:
It might be nice to add an
update
anddelete
methods with similar API:Note: I don't really care if you use this or not since I'm not using Drift directly. It's just a suggestion. Use it or close it as you see fit. ;-)
Btw. this is incorrect since it's a delete method.