Can someone point me towards a resource or show me an example of a good way of writing sql statements in php.
Most statements seem so ugly and unreadable.
You can use php/mssql extensions .
While PHP often does mediate between SQL and HTML its is capable of doing many more things and does not require SQL at all. In your scenario; HTML is how you view data, MySQL is how you store data, PHP is how you control the process of getting data from MySQL to HTML.
Code sample:
$stmt = $pdo->prepare('
SELECT ...
FROM ...
JOIN ...
JOIN ...
WHERE ... AND abc = :abc AND def = :def
');
$stmt->execute(array(
'abc' => 'abc value',
'def' => 'def value'
));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With