-
-
Save Zvax/5d4341ea99adf5205d2f72ac7d23bb5a to your computer and use it in GitHub Desktop.
some entity collection shit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function fetchSomeCollection(SomeCollection $collection): bool | |
{ | |
if (($condition = $collection->getCondition()) && ($id = $condition->getId())) { | |
$stmt = $this->pdo->prepare(' | |
SELECT manyShits | |
FROM aTable | |
JOIN someShit | |
JOIN someMoreShit | |
WHERE anCondition=:id | |
ORDER BY suchOrder | |
'); | |
$stmt->bindValue(':id', $id, PDO::PARAM_INT); | |
$stmt->execute(); | |
foreach ($stmt->fetchAll() as $row) { | |
$collection[] = (new SomeEntity) | |
->setProperty($row['property']); // many times | |
} | |
return true; | |
} | |
throw new \LogicException('you tried to fetch a collection without recognized condition you fucktard'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment