Skip to content

Instantly share code, notes, and snippets.

@Ronmi
Last active August 29, 2015 14:01
Show Gist options
  • Save Ronmi/385c9c37feccf913cd77 to your computer and use it in GitHub Desktop.
Save Ronmi/385c9c37feccf913cd77 to your computer and use it in GitHub Desktop.
某 SQL Builder 將使用的 FROM 建立語法
<?php
// (`model1` LEFT JOIN `model2` ON `model2`.`col2`=`model1`.`id`)
$from = $b->tables(
$b->left_join($m1, $m2, $b->eq($m2->col2, $m1->id))
);
// `model1`,`model2`,`model3`
$from = $b->tables($m1, $m2, $m3);
//((`model2` LEFT JOIN `model3` ON `model2`.`col2`=`model3`.`id`) LEFT JOIN `model1` ON `model2`.`col2`=`model1`.`id`)
$from = $b->tables(
$b->left_join(
$b->left_join($m2, $m3, $b->eq($m2->col2, $m3->id)),
$m1,
$b->eq($m2->col2, $m1->id)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment