In PHP, I use a lot of one liners like:
Fetch value:
$sql->query("SELECT ID FROM table WHERE condition = 1")->fetch_object()->ID;
Fetch row:
$sql->query("SELECT * FROM table WHERE condition = 1")->fetch_assoc();
Fetch rows:
$sql->query("SELECT * FROM table WHERE condition > 1")->fetch_all(MYSQLI_ASSOC);
Insert row:
$sql->query("INSERT INTO table(`row1`,`row2`) VALUES('".$data1."','".$data2."')");
Delete row:
$sql->query("DELETE FROM table WHERE condition = 1");
Are there also beautiful one liners for prepared statements?
This fails:
$sql->prepare("SELECT ID FROM table WHERE condition = ?")->bind_param("i", $a=1)->execute()->fetch_object()->ID;
This works:
$query = $sql->prepare("SELECT ID FROM table WHERE condition = ?");
$query->bind_param("i", $a=1);
$query->execute();
$query->get_result()->fetch_object()->ID;