This file contains hidden or 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
| $users = DB::table('users') | |
| ->where('deleted', '<>', 1) | |
| ->get(); | |
This file contains hidden or 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
| $sql = DB::table('users') | |
| ->where('deleted', '<>', 1); | |
| dd($sql->toSql(), $sql->getBindings()); | |
This file contains hidden or 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
| string(43) "select * from `users` where `deleted` <> ?" | |
This file contains hidden or 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
| DB::enableQueryLog(); | |
| //ここで表示したい実行のquery | |
| $queries = DB::getQueryLog(); | |
| print_r($queries); | |
This file contains hidden or 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
| <?php | |
| DB::last_query(); | |
This file contains hidden or 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
| <?php | |
| // DBクラスを使用しSQLを実行 | |
| $query = DB::select()->from('user'); | |
| $query->where('deleted', 1); | |
| $res = $query->execute()->as_array(); | |
| // 実行したSQLクエリを表示 | |
| var_dump(DB::last_query()); |
This file contains hidden or 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
| <?php | |
| $query = Doctrine_Query::create()->select('id')->from('MyTable'); | |
| $query->where('normalisedname = ? OR name = ?', array($string, $originalString)); | |
| echo sprintf(str_replace('?', '%s', $query->getSql()), $query->getParams()); | |
This file contains hidden or 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
| <?php | |
| $query = new Books::find()->where('author=2'); | |
This file contains hidden or 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
| <?php | |
| $query = new Books::find()->where('author=2'); | |
| //↓これ | |
| echo $query->createCommand()->sql; | |
This file contains hidden or 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
| <?php | |
| $query = new Books::find()->where('author=2'); | |
| //↓これ | |
| echo $query->createCommand()->getRawSql(); | |