本文整理汇总了PHP中Propel\Runtime\Propel::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Propel::log方法的具体用法?PHP Propel::log怎么用?PHP Propel::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\Propel
的用法示例。
在下文中一共展示了Propel::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findPkSimple
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @throws \Propel\Runtime\Exception\PropelException
*
* @return ChildTip A model object, or null if the key is not found
*/
protected function findPkSimple($key, ConnectionInterface $con)
{
$sql = 'SELECT id, bet, toto, joker, extra_joker, points, match_id, player_id FROM tips WHERE id = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
/** @var ChildTip $obj */
$obj = new ChildTip();
$obj->hydrate($row);
TipTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
示例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[ContentTableMap::ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentTableMap::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(ContentTableMap::ID)) {
$modifiedColumns[':p' . $index++] = '`ID`';
}
if ($this->isColumnModified(ContentTableMap::VISIBLE)) {
$modifiedColumns[':p' . $index++] = '`VISIBLE`';
}
if ($this->isColumnModified(ContentTableMap::POSITION)) {
$modifiedColumns[':p' . $index++] = '`POSITION`';
}
if ($this->isColumnModified(ContentTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = '`CREATED_AT`';
}
if ($this->isColumnModified(ContentTableMap::UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
}
if ($this->isColumnModified(ContentTableMap::VERSION)) {
$modifiedColumns[':p' . $index++] = '`VERSION`';
}
if ($this->isColumnModified(ContentTableMap::VERSION_CREATED_AT)) {
$modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
}
if ($this->isColumnModified(ContentTableMap::VERSION_CREATED_BY)) {
$modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
}
$sql = sprintf('INSERT INTO `content` (%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 '`VISIBLE`':
$stmt->bindValue($identifier, $this->visible, 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;
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);
}
示例3: findPkSimple
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildGoogleshoppingProductSynchronisation A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, PRODUCT_ID, TARGET_COUNTRY, LANG, SYNC_ENABLE, GOOGLESHOPPING_ACCOUNT_ID FROM googleshopping_product_synchronisation WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildGoogleshoppingProductSynchronisation();
$obj->hydrate($row);
GoogleshoppingProductSynchronisationTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
示例4: doInsert
//.........这里部分代码省略.........
$modifiedColumns[':p' . $index++] = 'REF';
}
if ($this->isColumnModified(CommentTableMap::REF_ID)) {
$modifiedColumns[':p' . $index++] = 'REF_ID';
}
if ($this->isColumnModified(CommentTableMap::EMAIL)) {
$modifiedColumns[':p' . $index++] = 'EMAIL';
}
if ($this->isColumnModified(CommentTableMap::TITLE)) {
$modifiedColumns[':p' . $index++] = 'TITLE';
}
if ($this->isColumnModified(CommentTableMap::CONTENT)) {
$modifiedColumns[':p' . $index++] = 'CONTENT';
}
if ($this->isColumnModified(CommentTableMap::RATING)) {
$modifiedColumns[':p' . $index++] = 'RATING';
}
if ($this->isColumnModified(CommentTableMap::STATUS)) {
$modifiedColumns[':p' . $index++] = 'STATUS';
}
if ($this->isColumnModified(CommentTableMap::VERIFIED)) {
$modifiedColumns[':p' . $index++] = 'VERIFIED';
}
if ($this->isColumnModified(CommentTableMap::ABUSE)) {
$modifiedColumns[':p' . $index++] = 'ABUSE';
}
if ($this->isColumnModified(CommentTableMap::LOCALE)) {
$modifiedColumns[':p' . $index++] = 'LOCALE';
}
if ($this->isColumnModified(CommentTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
if ($this->isColumnModified(CommentTableMap::UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = 'UPDATED_AT';
}
$sql = sprintf('INSERT INTO comment (%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 'CUSTOMER_ID':
$stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
break;
case 'REF':
$stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
break;
case 'REF_ID':
$stmt->bindValue($identifier, $this->ref_id, PDO::PARAM_INT);
break;
case 'EMAIL':
$stmt->bindValue($identifier, $this->email, PDO::PARAM_STR);
break;
case 'TITLE':
$stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
break;
case 'CONTENT':
$stmt->bindValue($identifier, $this->content, PDO::PARAM_STR);
break;
case 'RATING':
$stmt->bindValue($identifier, $this->rating, PDO::PARAM_INT);
break;
case 'STATUS':
$stmt->bindValue($identifier, $this->status, PDO::PARAM_INT);
break;
case 'VERIFIED':
$stmt->bindValue($identifier, $this->verified, PDO::PARAM_INT);
break;
case 'ABUSE':
$stmt->bindValue($identifier, $this->abuse, PDO::PARAM_INT);
break;
case 'LOCALE':
$stmt->bindValue($identifier, $this->locale, 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);
}
示例5: findPkSimple
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @throws \Propel\Runtime\Exception\PropelException
*
* @return ChildPeople A model object, or null if the key is not found
*/
protected function findPkSimple($key, ConnectionInterface $con)
{
$sql = 'SELECT id, name, date, city, street, fix_text, normal, company FROM people WHERE id = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
/** @var ChildPeople $obj */
$obj = new ChildPeople();
$obj->hydrate($row);
PeopleTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key);
}
$stmt->closeCursor();
return $obj;
}
示例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[WishlistProductTableMap::COL_WISHLIST_PRODUCT_ID] = true;
if (null !== $this->wishlist_product_id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . WishlistProductTableMap::COL_WISHLIST_PRODUCT_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(WishlistProductTableMap::COL_WISHLIST_PRODUCT_ID)) {
$modifiedColumns[':p' . $index++] = 'wishlist_product_id';
}
if ($this->isColumnModified(WishlistProductTableMap::COL_WISHLIST_ID)) {
$modifiedColumns[':p' . $index++] = 'wishlist_id';
}
if ($this->isColumnModified(WishlistProductTableMap::COL_PRODUCT_ID)) {
$modifiedColumns[':p' . $index++] = 'product_id';
}
if ($this->isColumnModified(WishlistProductTableMap::COL_WISHLIST_PRODUCT_COMMENT)) {
$modifiedColumns[':p' . $index++] = 'wishlist_product_comment';
}
if ($this->isColumnModified(WishlistProductTableMap::COL_CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'created_at';
}
if ($this->isColumnModified(WishlistProductTableMap::COL_UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = 'updated_at';
}
$sql = sprintf('INSERT INTO wishlist_product (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'wishlist_product_id':
$stmt->bindValue($identifier, $this->wishlist_product_id, PDO::PARAM_INT);
break;
case 'wishlist_id':
$stmt->bindValue($identifier, $this->wishlist_id, PDO::PARAM_INT);
break;
case 'product_id':
$stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
break;
case 'wishlist_product_comment':
$stmt->bindValue($identifier, $this->wishlist_product_comment, 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->setWishlistProductId($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[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);
}
//.........这里部分代码省略.........
示例8: doInsert
/**
* Insert the row in the database.
*
* @param ConnectionInterface $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(ModuleImageI18nTableMap::ID)) {
$modifiedColumns[':p' . $index++] = '`ID`';
}
if ($this->isColumnModified(ModuleImageI18nTableMap::LOCALE)) {
$modifiedColumns[':p' . $index++] = '`LOCALE`';
}
if ($this->isColumnModified(ModuleImageI18nTableMap::TITLE)) {
$modifiedColumns[':p' . $index++] = '`TITLE`';
}
if ($this->isColumnModified(ModuleImageI18nTableMap::DESCRIPTION)) {
$modifiedColumns[':p' . $index++] = '`DESCRIPTION`';
}
if ($this->isColumnModified(ModuleImageI18nTableMap::CHAPO)) {
$modifiedColumns[':p' . $index++] = '`CHAPO`';
}
if ($this->isColumnModified(ModuleImageI18nTableMap::POSTSCRIPTUM)) {
$modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`';
}
$sql = sprintf('INSERT INTO `module_image_i18n` (%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 '`LOCALE`':
$stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
break;
case '`TITLE`':
$stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
break;
case '`DESCRIPTION`':
$stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
break;
case '`CHAPO`':
$stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
break;
case '`POSTSCRIPTUM`':
$stmt->bindValue($identifier, $this->postscriptum, 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);
}
$this->setNew(false);
}
示例9: findPkSimple
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildInseeGeoDepartment A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, MAIN_MUNICIPALITY_ID, REGION_ID, GEO_POINT2D_X, GEO_POINT2D_Y, GEO_SHAPE, CREATED_AT, UPDATED_AT FROM insee_geo_department WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_STR);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildInseeGeoDepartment();
$obj->hydrate($row);
InseeGeoDepartmentTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
示例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[GroupTableMap::COL_ID] = true;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupTableMap::COL_ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(GroupTableMap::COL_ID)) {
$modifiedColumns[':p' . $index++] = 'id';
}
if ($this->isColumnModified(GroupTableMap::COL_NAME)) {
$modifiedColumns[':p' . $index++] = 'name';
}
if ($this->isColumnModified(GroupTableMap::COL_DESCRIPTION)) {
$modifiedColumns[':p' . $index++] = 'description';
}
if ($this->isColumnModified(GroupTableMap::COL_OWNER_ID)) {
$modifiedColumns[':p' . $index++] = 'owner_id';
}
if ($this->isColumnModified(GroupTableMap::COL_CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'created_at';
}
if ($this->isColumnModified(GroupTableMap::COL_UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = 'updated_at';
}
$sql = sprintf('INSERT INTO group_of_users (%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 'name':
$stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
break;
case 'description':
$stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
break;
case 'owner_id':
$stmt->bindValue($identifier, $this->owner_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;
}
}
$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: 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);
}
示例12: findPkSimple
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildDebit A model object, or null if the key is not found
*/
protected function findPkSimple($key, ConnectionInterface $con)
{
$sql = 'SELECT ID, PURCHASE_ID, TOTAL, PAID, STATUS FROM debit WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
/** @var ChildDebit $obj */
$obj = new ChildDebit();
$obj->hydrate($row);
DebitTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
示例13: findPkSimple
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @throws \Propel\Runtime\Exception\PropelException
*
* @return ChildPlayersOld A model object, or null if the key is not found
*/
protected function findPkSimple($key, ConnectionInterface $con)
{
$sql = 'SELECT ID, lastn, bats, bday, age, mlb, draft_year, position, card, d_e, lg, mwbl, category, comment, mwbl_link, mlb_link, mwbl_link_enabled, mlb_link_enabled FROM players_old WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
/** @var ChildPlayersOld $obj */
$obj = new ChildPlayersOld();
$obj->hydrate($row);
PlayersOldTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
示例14: findPkSimple
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildAccessory A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `PRODUCT_ID`, `ACCESSORY`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `accessory` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildAccessory();
$obj->hydrate($row);
AccessoryTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
示例15: findPkSimple
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @throws \Propel\Runtime\Exception\PropelException
*
* @return ChildPermissionGroupUser A model object, or null if the key is not found
*/
protected function findPkSimple($key, ConnectionInterface $con)
{
$sql = 'SELECT `user_id`, `group_id` FROM `permission_group_user` WHERE `user_id` = :p0 AND `group_id` = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
$stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
/** @var ChildPermissionGroupUser $obj */
$obj = new ChildPermissionGroupUser();
$obj->hydrate($row);
PermissionGroupUserTableMap::addInstanceToPool($obj, serialize([null === $key[0] || is_scalar($key[0]) || is_callable([$key[0], '__toString']) ? (string) $key[0] : $key[0], null === $key[1] || is_scalar($key[1]) || is_callable([$key[1], '__toString']) ? (string) $key[1] : $key[1]]));
}
$stmt->closeCursor();
return $obj;
}