LoginSignup
3
3

More than 5 years have passed since last update.

PHPからMySQLに接続してレコードを挿入する1

Last updated at Posted at 2015-03-19

前提

PHPからMySQLに接続する にて接続を行っている

コード(処理部分のみ)

テーブル: hogetable に以下のようなレコードを挿入する。

id name pass
1 yamada hogehoge
$stmt = $dbh->prepare("insert into hogetable (id,name,pass) values (:id,:name,:pass)");
$stmt->execute(array(":id"=>"1",":name"=>"yamada",":pass"=>"hogehoge"));    // 配列(array)で書く

その他

:変数名 のことをプレースホルダーという

3
3
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
3
3