25
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CodeIgniterのActive Recodeで実行したSQLを確認

Posted at

Active Recodeで書いているとたまにSQLはどんな感じになっているのか気になるときがあります

クエリを実行後に$this->db->last_query()で確認できます。
echoで呼び出せばOKです。

echo $this->db->last_query();

実際に書くとこんな感じ。

model.php
$this->db->select('user_id');
$this->db->from('user');
$query = $this->db->get();
echo $this->db->last_query();

結果表示はこんな感じです

SELECT `user_id` FROM (`user`)

参考: php - Getting CodeIgniter Active Record's current SQL code - Stack Overflow

25
30
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?