メインコンテンツまでスキップ
Version: Fegg 5.x(開発版)

Pdo::insert

Set insert query

Description​

public self Pdo::insert( string $table )

Builds an INSERT on $table from the values set with setValues (or setItem). created, modified and valid are added unless given (see Configuration). Run it with execute and read the new ID with getLastIndexId.

Arguments​

NameData typeDefaultRemarks
$tablestringTarget table name

Example​

Controller
$db = new \Fegg\Database\Pdo();

// Insert Into "cms_news" ("title", "category", modified, created, valid) Values (?, ?, ?, ?, ?)
$db->setValues(array('title' => 'Sample', 'category' => 2))->insert('cms_news')->execute();
$id = $db->getLastIndexId();
// -> '24'