If you want to delete a bunch of records, I would recommend using one of the following:
// fDatabase placeholders can handle arrays of value when not using prepared statements
$db->execute("DELETE FROM users WHERE user_id IN (%i)", $checkboxes);
or
// Here we use a prepared statement to reduce the amount of work done for each call
$statement = $db->prepare("DELETE FROM users WHERE user_id = %i");
foreach ($checkboxes as $id) {
$db->execute($statement, $id);
}
I'm not sure which would be faster, but using $db->enableDebugging(TRUE);
it would be pretty easy to tell.
There is no query generator for Flourish. If you use the ORM there is
fRecordSet, which provides some simplified querying of rows, but it relies on you using the ORM, which provides knowledge of the structure of your database.
Many of the cross-database libraries implement a query builder since different databases use slightly different constructs. Flourish instead provides the ability to run homogenized SQL that is then translated to the SQL dialect of the database you have connected to. You can see FlourishSql for the features that are supported.
Here's an example from Yii:
$user = Yii::app()->db->createCommand()
->select('id, username, profile')
->from('tbl_user u')
->join('tbl_profile p', 'u.id=p.user_id')
->where('id=:id', array(':id'=>$id))
->queryRow();
As compared to Flourish:
$user = $db->translatedQuery(
"SELECT
id, username, profile
FROM
tbl_user u INNER JOIN
tbl_profile p ON u.id = p.user_id
WHERE
id = %i",
$id
)->fetchRow();
As you can see, they are pretty similar. I think the real maintainability wins come from then you can automatically infer the FROM
clause based on the database structure. - this is what fRecordSet::build() does. You can reference columns in related tables without having to do any JOIN
s, which is especially useful when you WHERE
conditions are built via if/else statements.