Posts tagged with “join

Using JOIN in a MySQL DELETE Command

Deleting from a table is simple enough. If, for example, we wanted to remove all the comments from a single user and we already know that user’s id we could run this command (employing the EasyPDO library in PHP): <?php $db->ExecuteSQL(“DELETE FROM comments WHERE user_id=?”,”i”,$id); ?> Now imagine we only have the user’s email and […]

Reading and writing to association tables in CakePHP

When two models have a HABTM relationship (resisting the urge to make a joke) there is necessarily a shared association table. But what if we want to store more information in that table? While, for example, an association table between Events and Waiters (with Events HABTM Waiters) would be very useful, it would be even […]