oscarotero / simple-crud

PHP library to provide magic CRUD in MySQL/Sqlite databases with zero configuration
MIT License
242 stars 58 forks source link

leftJoin #28

Closed iAyubAnsari closed 6 years ago

iAyubAnsari commented 6 years ago

how to execute leftJoin function on select query?

oscarotero commented 6 years ago

You only have to add the leftJoin to the select, with the table name and, optionally a condition and mark.

$posts = $db->post->select()
    ->leftJoin('user', 'user.isVisible = :visible', [':visible' => 1])
    ->run();

foreach($posts as $post) {
    echo $post->user;
}
iAyubAnsari commented 6 years ago

pardon sir, I cant understand that, how can i execute this :) $query="SELECT * FROM contact_book LEFT JOIN conversations ON contact_book.id=conversations.contact_id ORDER BY conversations.id DESC";

oscarotero commented 6 years ago

To execute raw queries, you can use $db->execute($query), but I suspect this library is not for you.

iAyubAnsari commented 6 years ago

Thank you sir