LoginSignup
4
2

More than 5 years have passed since last update.

【Phalcon】Phalconで生のSQLを実行する【PHP】

Posted at

「phalcon 生SQL 実行」で検索しても、「実行したクエリを取得する」みたいなのしか出てこなかったので

◯◯.php
#model
use Phalcon\Db\Column;
use Phalcon\Db\Adapter\Pdo\Mysql;


class ◯◯ extends \Daisy\Util\Model
{
  public function initialize()
    {
      $this->adapter = $this->di->get('db');
    }
  public function test(){
    $ret = $this->adapter->fetchAll("SELECT * FROM user WHERE id = 1");
  }
}

Phalcon勉強会資料
ここ見てレコード数多いときはPDOを使うのがめっちゃ早いっぽい。

抽象クラスPhalcon \ Db \ Adapter \ Pdoのメソッド一覧
fetchAllは全部持ってくるやつだけど他にも便利なのがたくさんあります。

4
2
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
4
2