$sql = "SELECT * FROM `Account` WHERE `id_client ` = ". (int) $_SESSION['id']; UPDATE users u SET u.balance = u.balance + ((SELECT SUM(d.sum) FROM user_deposits d WHERE d.user_id=u.id)/100*5) INSERT INTO `table` ... `text` = Привет SELECT * FROM admins limit 1?INSERT INTO `table` ... `text` = "Привет SELECT * FROM admins limit 1"+SELECT COUNT(COUNT)?SELECT COUNT(`count`)+ SELECT
`a`.`id` AS `projectId`,
`a`.`url` AS `projectUrl`,
GROUP_CONCAT(`c`.`photo` SEPARATOR ', ') AS `photos`
FROM `projects` AS `a`
LEFT JOIN `personal` AS `b` ON `b`.`project` = `a`.`id`(?)
LEFT JOIN `users` AS `c` ON `c`.`id` = `b`.`user`<input type="checkbox" name="delete_ids[]" value="<=$model-id?>" />SELECT
a.*,
b.*
FROM
`tbl_1` AS a
LEFT JOIN
`tbl_2` AS b
ON
a.`id` = b.`parent_id`
GROUP BY
a.`id`
ORDER BY
MIN(b.`status`) ASCSELECT
a.*,
b.*
FROM
`tbl_1` AS a
LEFT JOIN
`tbl_2` AS b
ON
a.`id` = b.`parent_id`
GROUP BY
a.`id`
ORDER BY
MAX(b.`status`) DESC INSERT INTO `table` (`ID`, `City`, `Color`)
SELECT `ID`, `City`, `Color`
FROM `users` WHERE `Name` = "Test"
// или если id не надо
INSERT INTO `table` (`ID`, `City`, `Color`)
SELECT null, `City`, `Color`
FROM `users` WHERE `Name` = "Test" <?php
class fruit {
public $name;
public $colour;
}
$sth = $dbh->prepare("SELECT name, colour FROM fruit");
$sth->execute();
$result = $sth->fetchAll(PDO::FETCH_CLASS, "fruit");
var_dump($result);
?>Вот в этом то и проблема. Я пытаюсь скрыть внутри класса всё взаимодействие с БД. А у вашем варианте это не так.
abstract class modelDB
{
public static function find()
{
$sth = $dbh->prepare("SELECT * FROM `". get_called_class() ."`");
$sth->execute();
return $sth->fetchAll(PDO::FETCH_CLASS, get_called_class());
}
}
class fruit extends modelDB {
public $name;
public $colour;
}
$result = fruit::find();