本文整理汇总了PHP中Propel\Runtime\Connection\ConnectionInterface::lastInsertId方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionInterface::lastInsertId方法的具体用法?PHP ConnectionInterface::lastInsertId怎么用?PHP ConnectionInterface::lastInsertId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\Connection\ConnectionInterface
的用法示例。
在下文中一共展示了ConnectionInterface::lastInsertId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doInsert
//.........这里部分代码省略.........
$modifiedColumns[':p' . $index++] = '`LOCALE`';
}
if ($this->isColumnModified(LangTableMap::URL)) {
$modifiedColumns[':p' . $index++] = '`URL`';
}
if ($this->isColumnModified(LangTableMap::DATE_FORMAT)) {
$modifiedColumns[':p' . $index++] = '`DATE_FORMAT`';
}
if ($this->isColumnModified(LangTableMap::TIME_FORMAT)) {
$modifiedColumns[':p' . $index++] = '`TIME_FORMAT`';
}
if ($this->isColumnModified(LangTableMap::DATETIME_FORMAT)) {
$modifiedColumns[':p' . $index++] = '`DATETIME_FORMAT`';
}
if ($this->isColumnModified(LangTableMap::DECIMAL_SEPARATOR)) {
$modifiedColumns[':p' . $index++] = '`DECIMAL_SEPARATOR`';
}
if ($this->isColumnModified(LangTableMap::THOUSANDS_SEPARATOR)) {
$modifiedColumns[':p' . $index++] = '`THOUSANDS_SEPARATOR`';
}
if ($this->isColumnModified(LangTableMap::DECIMALS)) {
$modifiedColumns[':p' . $index++] = '`DECIMALS`';
}
if ($this->isColumnModified(LangTableMap::BY_DEFAULT)) {
$modifiedColumns[':p' . $index++] = '`BY_DEFAULT`';
}
if ($this->isColumnModified(LangTableMap::POSITION)) {
$modifiedColumns[':p' . $index++] = '`POSITION`';
}
if ($this->isColumnModified(LangTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = '`CREATED_AT`';
}
if ($this->isColumnModified(LangTableMap::UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
}
$sql = sprintf('INSERT INTO `lang` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`ID`':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case '`TITLE`':
$stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
break;
case '`CODE`':
$stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
break;
case '`LOCALE`':
$stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
break;
case '`URL`':
$stmt->bindValue($identifier, $this->url, PDO::PARAM_STR);
break;
case '`DATE_FORMAT`':
$stmt->bindValue($identifier, $this->date_format, PDO::PARAM_STR);
break;
case '`TIME_FORMAT`':
$stmt->bindValue($identifier, $this->time_format, PDO::PARAM_STR);
break;
case '`DATETIME_FORMAT`':
$stmt->bindValue($identifier, $this->datetime_format, PDO::PARAM_STR);
break;
case '`DECIMAL_SEPARATOR`':
$stmt->bindValue($identifier, $this->decimal_separator, PDO::PARAM_STR);
break;
case '`THOUSANDS_SEPARATOR`':
$stmt->bindValue($identifier, $this->thousands_separator, PDO::PARAM_STR);
break;
case '`DECIMALS`':
$stmt->bindValue($identifier, $this->decimals, PDO::PARAM_STR);
break;
case '`BY_DEFAULT`':
$stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT);
break;
case '`POSITION`':
$stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
break;
case '`CREATED_AT`':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case '`UPDATED_AT`':
$stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例2: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[ApplicationTableMap::COL_ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . ApplicationTableMap::COL_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(ApplicationTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'id';
}
if ($this->isColumnModified(ApplicationTableMap::COL_STUDENT_ID)) {
$modifiedColumns[':p' . $index++] = 'student_id';
}
if ($this->isColumnModified(ApplicationTableMap::COL_SUBJECT_ID)) {
$modifiedColumns[':p' . $index++] = 'subject_id';
}
if ($this->isColumnModified(ApplicationTableMap::COL_PERIOD_ID)) {
$modifiedColumns[':p' . $index++] = 'period_id';
}
if ($this->isColumnModified(ApplicationTableMap::COL_SCHOOL_YEAR_ID)) {
$modifiedColumns[':p' . $index++] = 'school_year_id';
}
if ($this->isColumnModified(ApplicationTableMap::COL_APPLICATION_DATE)) {
$modifiedColumns[':p' . $index++] = 'application_date';
}
if ($this->isColumnModified(ApplicationTableMap::COL_EXAM_DATE)) {
$modifiedColumns[':p' . $index++] = 'exam_date';
}
if ($this->isColumnModified(ApplicationTableMap::COL_EXAM_TIME)) {
$modifiedColumns[':p' . $index++] = 'exam_time';
}
if ($this->isColumnModified(ApplicationTableMap::COL_EXAM_SCORE)) {
$modifiedColumns[':p' . $index++] = 'exam_score';
}
if ($this->isColumnModified(ApplicationTableMap::COL_CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'created_at';
}
if ($this->isColumnModified(ApplicationTableMap::COL_UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = 'updated_at';
}
$sql = sprintf('INSERT INTO application (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'id':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'student_id':
$stmt->bindValue($identifier, $this->student_id, PDO::PARAM_INT);
break;
case 'subject_id':
$stmt->bindValue($identifier, $this->subject_id, PDO::PARAM_INT);
break;
case 'period_id':
$stmt->bindValue($identifier, $this->period_id, PDO::PARAM_INT);
break;
case 'school_year_id':
$stmt->bindValue($identifier, $this->school_year_id, PDO::PARAM_INT);
break;
case 'application_date':
$stmt->bindValue($identifier, $this->application_date ? $this->application_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'exam_date':
$stmt->bindValue($identifier, $this->exam_date ? $this->exam_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'exam_time':
$stmt->bindValue($identifier, $this->exam_time ? $this->exam_time->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'exam_score':
$stmt->bindValue($identifier, $this->exam_score, PDO::PARAM_INT);
break;
case 'created_at':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'updated_at':
$stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
//.........这里部分代码省略.........
示例3: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[JaCategoriasTableMap::COL_ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . JaCategoriasTableMap::COL_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(JaCategoriasTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'id';
}
if ($this->isColumnModified(JaCategoriasTableMap::COL_TITULO)) {
$modifiedColumns[':p' . $index++] = 'titulo';
}
if ($this->isColumnModified(JaCategoriasTableMap::COL_SLUG)) {
$modifiedColumns[':p' . $index++] = 'slug';
}
$sql = sprintf('INSERT INTO ja_categorias (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'id':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'titulo':
$stmt->bindValue($identifier, $this->titulo, PDO::PARAM_STR);
break;
case 'slug':
$stmt->bindValue($identifier, $this->slug, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例4: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[UserTableMap::COL_ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserTableMap::COL_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(UserTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(UserTableMap::COL_USERNAME)) {
$modifiedColumns[':p' . $index++] = 'USERNAME';
}
if ($this->isColumnModified(UserTableMap::COL_PASSWORD)) {
$modifiedColumns[':p' . $index++] = 'PASSWORD';
}
if ($this->isColumnModified(UserTableMap::COL_FIRST_NAME)) {
$modifiedColumns[':p' . $index++] = 'FIRST_NAME';
}
if ($this->isColumnModified(UserTableMap::COL_LAST_NAME)) {
$modifiedColumns[':p' . $index++] = 'LAST_NAME';
}
if ($this->isColumnModified(UserTableMap::COL_CREATE_DATE)) {
$modifiedColumns[':p' . $index++] = 'CREATE_DATE';
}
if ($this->isColumnModified(UserTableMap::COL_UPDATE_DATE)) {
$modifiedColumns[':p' . $index++] = 'UPDATE_DATE';
}
if ($this->isColumnModified(UserTableMap::COL_STATUS)) {
$modifiedColumns[':p' . $index++] = 'STATUS';
}
$sql = sprintf('INSERT INTO user (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'ID':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'USERNAME':
$stmt->bindValue($identifier, $this->username, PDO::PARAM_STR);
break;
case 'PASSWORD':
$stmt->bindValue($identifier, $this->password, PDO::PARAM_STR);
break;
case 'FIRST_NAME':
$stmt->bindValue($identifier, $this->first_name, PDO::PARAM_STR);
break;
case 'LAST_NAME':
$stmt->bindValue($identifier, $this->last_name, PDO::PARAM_STR);
break;
case 'CREATE_DATE':
$stmt->bindValue($identifier, $this->create_date ? $this->create_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'UPDATE_DATE':
$stmt->bindValue($identifier, $this->update_date ? $this->update_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'STATUS':
$stmt->bindValue($identifier, $this->status, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例5: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[DataTableMap::COL_ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . DataTableMap::COL_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(DataTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'id';
}
if ($this->isColumnModified(DataTableMap::COL__FORCONTRIBUTION)) {
$modifiedColumns[':p' . $index++] = '_forcontribution';
}
if ($this->isColumnModified(DataTableMap::COL__FORTEMPLATEFIELD)) {
$modifiedColumns[':p' . $index++] = '_fortemplatefield';
}
if ($this->isColumnModified(DataTableMap::COL__CONTENT)) {
$modifiedColumns[':p' . $index++] = '_content';
}
if ($this->isColumnModified(DataTableMap::COL__ISJSON)) {
$modifiedColumns[':p' . $index++] = '_isjson';
}
if ($this->isColumnModified(DataTableMap::COL___USER__)) {
$modifiedColumns[':p' . $index++] = '__user__';
}
if ($this->isColumnModified(DataTableMap::COL___CONFIG__)) {
$modifiedColumns[':p' . $index++] = '__config__';
}
if ($this->isColumnModified(DataTableMap::COL___SPLIT__)) {
$modifiedColumns[':p' . $index++] = '__split__';
}
if ($this->isColumnModified(DataTableMap::COL___PARENTNODE__)) {
$modifiedColumns[':p' . $index++] = '__parentnode__';
}
if ($this->isColumnModified(DataTableMap::COL___SORT__)) {
$modifiedColumns[':p' . $index++] = '__sort__';
}
$sql = sprintf('INSERT INTO _data (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'id':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case '_forcontribution':
$stmt->bindValue($identifier, $this->_forcontribution, PDO::PARAM_INT);
break;
case '_fortemplatefield':
$stmt->bindValue($identifier, $this->_fortemplatefield, PDO::PARAM_INT);
break;
case '_content':
$stmt->bindValue($identifier, $this->_content, PDO::PARAM_STR);
break;
case '_isjson':
$stmt->bindValue($identifier, (int) $this->_isjson, PDO::PARAM_INT);
break;
case '__user__':
$stmt->bindValue($identifier, $this->__user__, PDO::PARAM_INT);
break;
case '__config__':
$stmt->bindValue($identifier, $this->__config__, PDO::PARAM_STR);
break;
case '__split__':
$stmt->bindValue($identifier, $this->__split__, PDO::PARAM_STR);
break;
case '__parentnode__':
$stmt->bindValue($identifier, $this->__parentnode__, PDO::PARAM_INT);
break;
case '__sort__':
$stmt->bindValue($identifier, $this->__sort__, PDO::PARAM_INT);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例6: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[WpUsermetaTableMap::COL_UMETA_ID] = true;
if (null !== $this->umeta_id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . WpUsermetaTableMap::COL_UMETA_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(WpUsermetaTableMap::COL_UMETA_ID)) {
$modifiedColumns[':p' . $index++] = 'umeta_id';
}
if ($this->isColumnModified(WpUsermetaTableMap::COL_USER_ID)) {
$modifiedColumns[':p' . $index++] = 'user_id';
}
if ($this->isColumnModified(WpUsermetaTableMap::COL_META_KEY)) {
$modifiedColumns[':p' . $index++] = 'meta_key';
}
if ($this->isColumnModified(WpUsermetaTableMap::COL_META_VALUE)) {
$modifiedColumns[':p' . $index++] = 'meta_value';
}
$sql = sprintf('INSERT INTO wp_usermeta (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'umeta_id':
$stmt->bindValue($identifier, $this->umeta_id, PDO::PARAM_INT);
break;
case 'user_id':
$stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT);
break;
case 'meta_key':
$stmt->bindValue($identifier, $this->meta_key, PDO::PARAM_STR);
break;
case 'meta_value':
$stmt->bindValue($identifier, $this->meta_value, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setUmetaId($pk);
$this->setNew(false);
}
示例7: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[MatchTableMap::COL_ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . MatchTableMap::COL_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(MatchTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'id';
}
if ($this->isColumnModified(MatchTableMap::COL_NR)) {
$modifiedColumns[':p' . $index++] = 'nr';
}
if ($this->isColumnModified(MatchTableMap::COL_DATE)) {
$modifiedColumns[':p' . $index++] = 'date';
}
if ($this->isColumnModified(MatchTableMap::COL_RESULT)) {
$modifiedColumns[':p' . $index++] = 'result';
}
if ($this->isColumnModified(MatchTableMap::COL_TOTO)) {
$modifiedColumns[':p' . $index++] = 'toto';
}
if ($this->isColumnModified(MatchTableMap::COL_CHAMPIONSHIP_ID)) {
$modifiedColumns[':p' . $index++] = 'championship_id';
}
if ($this->isColumnModified(MatchTableMap::COL_ROUND_ID)) {
$modifiedColumns[':p' . $index++] = 'round_id';
}
if ($this->isColumnModified(MatchTableMap::COL_LEAGUE_ID)) {
$modifiedColumns[':p' . $index++] = 'league_id';
}
if ($this->isColumnModified(MatchTableMap::COL_HOMETEAM_ID)) {
$modifiedColumns[':p' . $index++] = 'hometeam_id';
}
if ($this->isColumnModified(MatchTableMap::COL_AWAYTEAM_ID)) {
$modifiedColumns[':p' . $index++] = 'awayteam_id';
}
$sql = sprintf('INSERT INTO matches (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'id':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'nr':
$stmt->bindValue($identifier, $this->nr, PDO::PARAM_INT);
break;
case 'date':
$stmt->bindValue($identifier, $this->date ? $this->date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'result':
$stmt->bindValue($identifier, $this->result, PDO::PARAM_STR);
break;
case 'toto':
$stmt->bindValue($identifier, $this->toto, PDO::PARAM_INT);
break;
case 'championship_id':
$stmt->bindValue($identifier, $this->championship_id, PDO::PARAM_INT);
break;
case 'round_id':
$stmt->bindValue($identifier, $this->round_id, PDO::PARAM_INT);
break;
case 'league_id':
$stmt->bindValue($identifier, $this->league_id, PDO::PARAM_INT);
break;
case 'hometeam_id':
$stmt->bindValue($identifier, $this->hometeam_id, PDO::PARAM_INT);
break;
case 'awayteam_id':
$stmt->bindValue($identifier, $this->awayteam_id, PDO::PARAM_INT);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例8: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[InvTypesTableMap::COL_TYPEID] = true;
if (null !== $this->typeid) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . InvTypesTableMap::COL_TYPEID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(InvTypesTableMap::COL_TYPEID)) {
$modifiedColumns[':p' . $index++] = 'typeID';
}
if ($this->isColumnModified(InvTypesTableMap::COL_GROUPID)) {
$modifiedColumns[':p' . $index++] = 'groupID';
}
if ($this->isColumnModified(InvTypesTableMap::COL_TYPENAME)) {
$modifiedColumns[':p' . $index++] = 'typeName';
}
if ($this->isColumnModified(InvTypesTableMap::COL_VOLUME)) {
$modifiedColumns[':p' . $index++] = 'volume';
}
if ($this->isColumnModified(InvTypesTableMap::COL_CAPACITY)) {
$modifiedColumns[':p' . $index++] = 'capacity';
}
if ($this->isColumnModified(InvTypesTableMap::COL_PUBLISHED)) {
$modifiedColumns[':p' . $index++] = 'published';
}
$sql = sprintf('INSERT INTO invtypes (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'typeID':
$stmt->bindValue($identifier, $this->typeid, PDO::PARAM_INT);
break;
case 'groupID':
$stmt->bindValue($identifier, $this->groupid, PDO::PARAM_INT);
break;
case 'typeName':
$stmt->bindValue($identifier, $this->typename, PDO::PARAM_STR);
break;
case 'volume':
$stmt->bindValue($identifier, $this->volume, PDO::PARAM_STR);
break;
case 'capacity':
$stmt->bindValue($identifier, $this->capacity, PDO::PARAM_STR);
break;
case 'published':
$stmt->bindValue($identifier, $this->published, PDO::PARAM_INT);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setTypeid($pk);
$this->setNew(false);
}
示例9: doInsert
//.........这里部分代码省略.........
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(NoteTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'id';
}
if ($this->isColumnModified(NoteTableMap::COL_USER_ID)) {
$modifiedColumns[':p' . $index++] = 'user_id';
}
if ($this->isColumnModified(NoteTableMap::COL_IMPORTANCE)) {
$modifiedColumns[':p' . $index++] = 'importance';
}
if ($this->isColumnModified(NoteTableMap::COL_TITLE)) {
$modifiedColumns[':p' . $index++] = 'title';
}
if ($this->isColumnModified(NoteTableMap::COL_DEADLINE)) {
$modifiedColumns[':p' . $index++] = 'deadline';
}
if ($this->isColumnModified(NoteTableMap::COL_CATEGORY_ID)) {
$modifiedColumns[':p' . $index++] = 'category_id';
}
if ($this->isColumnModified(NoteTableMap::COL_STATE)) {
$modifiedColumns[':p' . $index++] = 'state';
}
if ($this->isColumnModified(NoteTableMap::COL_REPEAT_AFTER)) {
$modifiedColumns[':p' . $index++] = 'repeat_after';
}
if ($this->isColumnModified(NoteTableMap::COL_DONE_AT)) {
$modifiedColumns[':p' . $index++] = 'done_at';
}
if ($this->isColumnModified(NoteTableMap::COL_PUBLIC)) {
$modifiedColumns[':p' . $index++] = 'public';
}
if ($this->isColumnModified(NoteTableMap::COL_DESCRIPTION)) {
$modifiedColumns[':p' . $index++] = 'description';
}
if ($this->isColumnModified(NoteTableMap::COL_CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'created_at';
}
if ($this->isColumnModified(NoteTableMap::COL_UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = 'updated_at';
}
$sql = sprintf('INSERT INTO note (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'id':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'user_id':
$stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT);
break;
case 'importance':
$stmt->bindValue($identifier, $this->importance, PDO::PARAM_INT);
break;
case 'title':
$stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
break;
case 'deadline':
$stmt->bindValue($identifier, $this->deadline ? $this->deadline->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'category_id':
$stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
break;
case 'state':
$stmt->bindValue($identifier, $this->state, PDO::PARAM_INT);
break;
case 'repeat_after':
$stmt->bindValue($identifier, $this->repeat_after, PDO::PARAM_INT);
break;
case 'done_at':
$stmt->bindValue($identifier, $this->done_at ? $this->done_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'public':
$stmt->bindValue($identifier, (int) $this->public, PDO::PARAM_INT);
break;
case 'description':
$stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
break;
case 'created_at':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'updated_at':
$stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例10: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = ActorTableMap::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . ActorTableMap::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(ActorTableMap::ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(ActorTableMap::MOVIE_ID)) {
$modifiedColumns[':p' . $index++] = 'MOVIE_ID';
}
if ($this->isColumnModified(ActorTableMap::NAME)) {
$modifiedColumns[':p' . $index++] = 'NAME';
}
if ($this->isColumnModified(ActorTableMap::SURNAME)) {
$modifiedColumns[':p' . $index++] = 'SURNAME';
}
$sql = sprintf('INSERT INTO actor (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'ID':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'MOVIE_ID':
$stmt->bindValue($identifier, $this->movie_id, PDO::PARAM_INT);
break;
case 'NAME':
$stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
break;
case 'SURNAME':
$stmt->bindValue($identifier, $this->surname, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例11: getId
/**
* Gets the generated ID (either last ID for autoincrement or next sequence ID).
*
* @param ConnectionInterface $con
* @param string $name
*
* @return mixed
*/
public function getId(ConnectionInterface $con, $name = null)
{
return $con->lastInsertId($name);
}
示例12: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[ДатыОбновленийДашбордовTableMap::COL_ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . ДатыОбновленийДашбордовTableMap::COL_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(ДатыОбновленийДашбордовTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'id';
}
if ($this->isColumnModified(ДатыОбновленийДашбордовTableMap::COL_ДашбнрХ)) {
$modifiedColumns[':p' . $index++] = 'Дашборд';
}
if ($this->isColumnModified(ДатыОбновленийДашбордовTableMap::COL_ЏрнеЪт)) {
$modifiedColumns[':p' . $index++] = 'Проект';
}
if ($this->isColumnModified(ДатыОбновленийДашбордовTableMap::COL_Дата)) {
$modifiedColumns[':p' . $index++] = 'Дата';
}
$sql = sprintf('INSERT INTO Даты_обновлений_дашбордов (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'id':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'Дашборд':
$stmt->bindValue($identifier, $this->�������, PDO::PARAM_STR);
break;
case 'Проект':
$stmt->bindValue($identifier, $this->������, PDO::PARAM_INT);
break;
case 'Дата':
$stmt->bindValue($identifier, $this->���� ? $this->����->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例13: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[InputErrorTableMap::COL_ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . InputErrorTableMap::COL_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(InputErrorTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'id';
}
if ($this->isColumnModified(InputErrorTableMap::COL_INPUT_UUID)) {
$modifiedColumns[':p' . $index++] = 'input_uuid';
}
if ($this->isColumnModified(InputErrorTableMap::COL_BER_AVERAGE)) {
$modifiedColumns[':p' . $index++] = 'ber_average';
}
if ($this->isColumnModified(InputErrorTableMap::COL_UNC_AVERAGE)) {
$modifiedColumns[':p' . $index++] = 'unc_average';
}
if ($this->isColumnModified(InputErrorTableMap::COL_CUMULATIVE_TE)) {
$modifiedColumns[':p' . $index++] = 'cumulative_te';
}
if ($this->isColumnModified(InputErrorTableMap::COL_CUMULATIVE_CC)) {
$modifiedColumns[':p' . $index++] = 'cumulative_cc';
}
if ($this->isColumnModified(InputErrorTableMap::COL_CREATED)) {
$modifiedColumns[':p' . $index++] = 'created';
}
if ($this->isColumnModified(InputErrorTableMap::COL_MODIFIED)) {
$modifiedColumns[':p' . $index++] = 'modified';
}
$sql = sprintf('INSERT INTO input_error (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'id':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'input_uuid':
$stmt->bindValue($identifier, $this->input_uuid, PDO::PARAM_STR);
break;
case 'ber_average':
$stmt->bindValue($identifier, $this->ber_average, PDO::PARAM_STR);
break;
case 'unc_average':
$stmt->bindValue($identifier, $this->unc_average, PDO::PARAM_STR);
break;
case 'cumulative_te':
$stmt->bindValue($identifier, $this->cumulative_te, PDO::PARAM_INT);
break;
case 'cumulative_cc':
$stmt->bindValue($identifier, $this->cumulative_cc, PDO::PARAM_INT);
break;
case 'created':
$stmt->bindValue($identifier, $this->created ? $this->created->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case 'modified':
$stmt->bindValue($identifier, $this->modified ? $this->modified->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例14: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[RatingCategoriesTableMap::COL_ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . RatingCategoriesTableMap::COL_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(RatingCategoriesTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(RatingCategoriesTableMap::COL_TITLE)) {
$modifiedColumns[':p' . $index++] = 'title';
}
if ($this->isColumnModified(RatingCategoriesTableMap::COL_DESCRIPTION)) {
$modifiedColumns[':p' . $index++] = 'description';
}
if ($this->isColumnModified(RatingCategoriesTableMap::COL_WEIGHT)) {
$modifiedColumns[':p' . $index++] = 'weight';
}
if ($this->isColumnModified(RatingCategoriesTableMap::COL_SEQUENCE)) {
$modifiedColumns[':p' . $index++] = 'sequence';
}
$sql = sprintf('INSERT INTO rating_categories (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'ID':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'title':
$stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
break;
case 'description':
$stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
break;
case 'weight':
$stmt->bindValue($identifier, $this->weight, PDO::PARAM_INT);
break;
case 'sequence':
$stmt->bindValue($identifier, $this->sequence, PDO::PARAM_INT);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例15: doInsert
//.........这里部分代码省略.........
$modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
}
if ($this->isColumnModified(OrderTableMap::VERSION_CREATED_BY)) {
$modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
}
$sql = sprintf('INSERT INTO `order` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`ID`':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case '`REF`':
$stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
break;
case '`CUSTOMER_ID`':
$stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
break;
case '`INVOICE_ORDER_ADDRESS_ID`':
$stmt->bindValue($identifier, $this->invoice_order_address_id, PDO::PARAM_INT);
break;
case '`DELIVERY_ORDER_ADDRESS_ID`':
$stmt->bindValue($identifier, $this->delivery_order_address_id, PDO::PARAM_INT);
break;
case '`INVOICE_DATE`':
$stmt->bindValue($identifier, $this->invoice_date ? $this->invoice_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case '`CURRENCY_ID`':
$stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT);
break;
case '`CURRENCY_RATE`':
$stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR);
break;
case '`TRANSACTION_REF`':
$stmt->bindValue($identifier, $this->transaction_ref, PDO::PARAM_STR);
break;
case '`DELIVERY_REF`':
$stmt->bindValue($identifier, $this->delivery_ref, PDO::PARAM_STR);
break;
case '`INVOICE_REF`':
$stmt->bindValue($identifier, $this->invoice_ref, PDO::PARAM_STR);
break;
case '`DISCOUNT`':
$stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR);
break;
case '`POSTAGE`':
$stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR);
break;
case '`POSTAGE_TAX`':
$stmt->bindValue($identifier, $this->postage_tax, PDO::PARAM_STR);
break;
case '`POSTAGE_TAX_RULE_TITLE`':
$stmt->bindValue($identifier, $this->postage_tax_rule_title, PDO::PARAM_STR);
break;
case '`PAYMENT_MODULE_ID`':
$stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT);
break;
case '`DELIVERY_MODULE_ID`':
$stmt->bindValue($identifier, $this->delivery_module_id, PDO::PARAM_INT);
break;
case '`STATUS_ID`':
$stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT);
break;
case '`LANG_ID`':
$stmt->bindValue($identifier, $this->lang_id, PDO::PARAM_INT);
break;
case '`CART_ID`':
$stmt->bindValue($identifier, $this->cart_id, PDO::PARAM_INT);
break;
case '`CREATED_AT`':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case '`UPDATED_AT`':
$stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case '`VERSION`':
$stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
break;
case '`VERSION_CREATED_AT`':
$stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
case '`VERSION_CREATED_BY`':
$stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', 0, $e);
}
$this->setId($pk);
$this->setNew(false);
}