本文整理汇总了PHP中PropelPDO::prepare方法的典型用法代码示例。如果您正苦于以下问题:PHP PropelPDO::prepare方法的具体用法?PHP PropelPDO::prepare怎么用?PHP PropelPDO::prepare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropelPDO
的用法示例。
在下文中一共展示了PropelPDO::prepare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doSetup
/**
* Do setup system. Execute once.
*
*/
public static function doSetup()
{
$IT_SPECIALIST_EMAIL = 'niko.neuhauser@gmail.com';
/* Setup - SYSTEM ACCOUNT
---------------------------------------------*/
self::createMember(null, ['LastName' => 'account', 'FirstName' => 'system', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_SYSTEM, 'Type' => \Member::TYPE_SYSTEM, 'FundsLevel' => \Member::FUNDS_LEVEL2]);
/* Setup - CEO1
---------------------------------------------*/
$ceo1 = self::createMember(null, ['FirstName' => 'Marcus', 'LastName' => 'CEO', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_CEO1, 'Type' => \Member::TYPE_CEO, 'FundsLevel' => \Member::FUNDS_LEVEL2]);
/* Setup - IT
---------------------------------------------*/
$it = self::createMember(null, ['FirstName' => 'System', 'LastName' => 'IT', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_IT, 'Type' => \Member::TYPE_ITSPECIALIST, 'FundsLevel' => \Member::FUNDS_LEVEL2]);
/* Setup - SYLVHEIM
---------------------------------------------*/
$sylvheim = self::createMember(null, ['ReferrerId' => $ceo1->getId(), 'FirstName' => 'Sales', 'LastName' => 'Management', 'Email' => 'test35@gmx.de', 'Num' => \SystemStats::ACCOUNT_SYLVHEIM, 'Type' => \Member::TYPE_SALES_MANAGER, 'FundsLevel' => \Member::FUNDS_LEVEL2]);
/* Setup - EXECUTIVE
---------------------------------------------*/
$executive = self::createMember(null, ['FirstName' => 'Administration', 'LastName' => 'Executive', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_EXECUTIVE, 'Type' => \Member::TYPE_MEMBER, 'FundsLevel' => \Member::FUNDS_LEVEL2]);
/* Setup - REASON_NGO_PROJECTS
---------------------------------------------*/
// $ngoProjects = self::createMember(null, [
// 'FirstName' => 'Projects',
// 'LastName' => 'NGO',
// 'Email' => $IT_SPECIALIST_EMAIL,
// 'Num' => \SystemStats::ACCOUNT_NGO_PROJECTS,
// 'Type' => \Member::TYPE_MEMBER,
// 'FundsLevel'=> \Member::FUNDS_LEVEL2
// ]);
/* Setup - TOP LEVEL BONUS IDS
---------------------------------------------*/
$topLvlBonusIds = json_encode([$ceo1->getId() => $ceo1->getType(), $it->getId() => $it->getType(), $executive->getId() => $executive->getType()]);
$salesManagerBonusIds = json_encode([$ceo1->getId() => $ceo1->getType(), $it->getId() => $it->getType(), $sylvheim->getId() => $sylvheim->getType(), $executive->getId() => $executive->getType()]);
$ceo1->setBonusIds($topLvlBonusIds);
$it->setBonusIds($topLvlBonusIds);
$sylvheim->setBonusIds($salesManagerBonusIds);
$executive->setBonusIds($topLvlBonusIds);
// $taricWani->setBonusIds($topLvlBonusIds);
// $ngoProjects->setBonusIds($topLvlBonusIds);
$ceo1->save(self::$con);
$it->save(self::$con);
$sylvheim->save(self::$con);
$executive->save(self::$con);
// $taricWani->save(self::$con);
// $ngoProjects->save(self::$con);
/* SET auto increment counter for member numbers
---------------------------------------------*/
$sql = "ALTER TABLE tbmt_member AUTO_INCREMENT=1000001";
$stmt = self::$con->prepare($sql);
$stmt->execute();
/* Setup - SYSTEM STATS
---------------------------------------------*/
$systemStats = new \SystemStats();
$systemStats->setInvitationIncrementer('2A15F6');
$systemStats->save();
}
示例2: getAvailableYearsForCourseId
public static function getAvailableYearsForCourseId($courseId, PropelPDO $propelConnection)
{
$query = "SELECT DISTINCT %s as y FROM %s JOIN %s ON %s=%s WHERE %s='%s' ORDER BY y DESC";
$query = sprintf($query, CourseInstructorAssociationPeer::YEAR, AutoCourseRatingPeer::TABLE_NAME, CourseInstructorAssociationPeer::TABLE_NAME, AutoCourseRatingPeer::COURSE_INS_ID, CourseInstructorAssociationPeer::ID, CourseInstructorAssociationPeer::COURSE_ID, $courseId);
$statement = $propelConnection->prepare($query);
$statement->execute();
$resultset = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
return $resultset;
}
示例3: getHistoricalInstructorsForCourseId
public static function getHistoricalInstructorsForCourseId($courseId, PropelPDO $propelConnection)
{
$query = "SELECT DISTINCT CONCAT(%s,', ',%s) AS name, %s FROM %s RIGHT JOIN %s ON %s=%s WHERE %s<>(SELECT MAX(%s) FROM %s WHERE %s='%s') AND %s='%s' ORDER BY name ASC";
$query = sprintf($query, InstructorPeer::LAST_NAME, InstructorPeer::FIRST_NAME, InstructorPeer::ID, InstructorPeer::TABLE_NAME, CourseInstructorAssociationPeer::TABLE_NAME, InstructorPeer::ID, CourseInstructorAssociationPeer::INSTRUCTOR_ID, CourseInstructorAssociationPeer::YEAR, CourseInstructorAssociationPeer::YEAR, CourseInstructorAssociationPeer::TABLE_NAME, CourseInstructorAssociationPeer::COURSE_ID, $courseId, CourseInstructorAssociationPeer::COURSE_ID, $courseId);
$statement = $propelConnection->prepare($query);
$statement->execute();
$resultset = $statement->fetchAll();
return $resultset;
}
示例4: getAvailableYearsForCourseId
public static function getAvailableYearsForCourseId($courseId, PropelPDO $propelConnection)
{
$query = "SELECT DISTINCT %s FROM %s WHERE %s='%s' ORDER BY %s DESC";
$query = sprintf($query, ExamPeer::YEAR, ExamPeer::TABLE_NAME, ExamPeer::COURSE_ID, $courseId, ExamPeer::YEAR);
$statement = $propelConnection->prepare($query);
$statement->execute();
$resultset = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
return $resultset;
}
示例5: computeDbLength
/**
* Computes the value of the aggregate column length
* Overridden to provide a default of 00:00:00 if the block is empty.
*
* @param PropelPDO $con A connection object
*
* @return mixed The scalar result from the aggregate query
*/
public function computeDbLength(PropelPDO $con)
{
$stmt = $con->prepare('SELECT SUM(cliplength) FROM "cc_blockcontents" WHERE cc_blockcontents.BLOCK_ID = :p1');
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
$length = $stmt->fetchColumn();
if (is_null($length)) {
$length = "00:00:00";
}
return $length;
}
示例6: doSetup
public static function doSetup()
{
$IT_SPECIALIST_EMAIL = 'niko.neuhauser@gmail.com';
/* Setup - SYSTEM ACCOUNT
---------------------------------------------*/
self::createMember(null, ['LastName' => 'system', 'FirstName' => 'account', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_SYSTEM, 'Type' => \Member::TYPE_SYSTEM]);
/* Setup - ROOT ACCOUNT
---------------------------------------------*/
self::createMember(null, ['LastName' => 'root', 'FirstName' => 'account', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_ROOT, 'Type' => \Member::TYPE_SYSTEM]);
/* Setup - CEO1
---------------------------------------------*/
$ceo1 = self::createMember(null, ['LastName' => 'system', 'FirstName' => 'ceo1', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_CEO1, 'Type' => \Member::TYPE_CEO]);
/* Setup - CEO2
---------------------------------------------*/
$ceo2 = self::createMember(null, ['LastName' => 'system', 'FirstName' => 'ceo2', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_CEO2, 'Type' => \Member::TYPE_CEO]);
/* Setup - IT
---------------------------------------------*/
$it = self::createMember(null, ['LastName' => 'system', 'FirstName' => 'it', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_IT, 'Type' => \Member::TYPE_MEMBER]);
/* Setup - LAWYER
---------------------------------------------*/
$lawyer = self::createMember(null, ['LastName' => 'system', 'FirstName' => 'lawyer', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_LAWYER, 'Type' => \Member::TYPE_MEMBER]);
/* Setup - TOP LEVEL BONUS IDS
---------------------------------------------*/
$topLvlBonusIds = json_encode([$ceo1->getId(), $ceo2->getId(), $it->getId(), $lawyer->getId()]);
$ceo1->setBonusIds($topLvlBonusIds);
$ceo2->setBonusIds($topLvlBonusIds);
$it->setBonusIds($topLvlBonusIds);
$lawyer->setBonusIds($topLvlBonusIds);
$ceo1->save(self::$con);
$ceo2->save(self::$con);
$it->save(self::$con);
$lawyer->save(self::$con);
/* SET auto increment counter for member numbers
---------------------------------------------*/
$sql = "SELECT setval('tbmt_member_num_seq', 1000001);";
$stmt = self::$con->prepare($sql);
$stmt->execute();
}
示例7: testDump
public function testDump()
{
$catalogue = new MessageCatalogue('en_US', array('test' => array('example.key' => 'This is an example translation.'), 'test2' => array('example.key' => 'This is an example translation.')));
$resource = $this->getResource();
$this->assertEmpty($resource->load($resource, 'en_US', 'test')->all());
$resource->dump($catalogue);
$stmt = $this->con->prepare('SELECT `key`, `message`, `locale`, `domain` FROM `translation`;');
$stmt->execute();
$result = array();
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$result[] = $row;
}
$expected = array(array('key' => 'example.key', 'message' => 'This is an example translation.', 'locale' => 'en_US', 'domain' => 'test'), array('key' => 'example.key', 'message' => 'This is an example translation.', 'locale' => 'en_US', 'domain' => 'test2'));
$this->assertEquals($expected, $result);
}
示例8: doBackupRecord
public static function doBackupRecord(\Criteria $criteria, PropelPDO $con)
{
$db = Propel::getDB($criteria->getDbName());
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$keys = $criteria->keys();
if (!empty($keys)) {
$tableName = $criteria->getTableName($keys[0]);
} else {
throw new PropelException("Database insert attempted without anything specified to insert");
}
$tableMap = $dbMap->getTable($tableName);
$whereClause = array();
$peer = $tableMap->getPeerClassname();
$versionTable = $peer::$workspaceBehaviorVersionName;
$originTable = $tableMap->getName();
$tables = $criteria->getTablesColumns();
if (empty($tables)) {
throw new \PropelException("Empty Criteria");
}
$fields = array_keys($tableMap->getColumns());
$fields = implode(', ', $fields);
foreach ($tables as $tableName => $columns) {
$whereClause = array();
$params = array();
$stmt = null;
try {
foreach ($columns as $colName) {
$sb = "";
$criteria->getCriterion($colName)->appendPsTo($sb, $params);
$whereClause[] = $sb;
}
$sql = sprintf("INSERT INTO %s (%s) SELECT %s FROM %s WHERE %s", $versionTable, $fields, $fields, $originTable, implode(" AND ", $whereClause));
$stmt = $con->prepare($sql);
$db->bindValues($stmt, $params, $dbMap);
$stmt->execute();
$stmt->closeCursor();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT INTO statement [%s]', $sql), $e);
}
}
// for each table
}
示例9: getAvailableInstructorsForCourseIdAndYear
public static function getAvailableInstructorsForCourseIdAndYear($courseId, $year, PropelPDO $conn)
{
$query = "SELECT DISTINCT %s as i FROM %s JOIN %s ON %s=%s WHERE %s='%s' AND %s=%s";
$query = sprintf($query, CourseInstructorAssociationPeer::ID, AutoCourseRatingPeer::TABLE_NAME, CourseInstructorAssociationPeer::TABLE_NAME, AutoCourseRatingPeer::COURSE_INS_ID, CourseInstructorAssociationPeer::ID, CourseInstructorAssociationPeer::COURSE_ID, $courseId, CourseInstructorAssociationPeer::YEAR, $year);
$statement = $conn->prepare($query);
$statement->execute();
$ids = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
$results = array();
$c = new Criteria();
$c->addJoin(CourseInstructorAssociationPeer::INSTRUCTOR_ID, InstructorPeer::ID);
foreach ($ids as $id) {
$crit = $c->getNewCriterion(CourseInstructorAssociationPeer::ID, $id);
$c->addOr($crit);
}
$c->addAscendingOrderByColumn(InstructorPeer::LAST_NAME);
$c->addAscendingOrderByColumn(InstructorPeer::FIRST_NAME);
$raw = CourseInstructorAssociationPeer::doSelectJoinInstructor($c, $conn);
foreach ($raw as $obj) {
$results[] = $obj->getInstructor();
}
return $results;
}
示例10: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = CountryPeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . CountryPeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(CountryPeer::ID)) {
$modifiedColumns[':p' . $index++] = '`ID`';
}
if ($this->isColumnModified(CountryPeer::NAME)) {
$modifiedColumns[':p' . $index++] = '`NAME`';
}
if ($this->isColumnModified(CountryPeer::ISO_CODE)) {
$modifiedColumns[':p' . $index++] = '`ISO_CODE`';
}
if ($this->isColumnModified(CountryPeer::ISO_SHORT_CODE)) {
$modifiedColumns[':p' . $index++] = '`ISO_SHORT_CODE`';
}
if ($this->isColumnModified(CountryPeer::DEMONYM)) {
$modifiedColumns[':p' . $index++] = '`DEMONYM`';
}
if ($this->isColumnModified(CountryPeer::DEFAULT_CURRENCY_ID)) {
$modifiedColumns[':p' . $index++] = '`DEFAULT_CURRENCY_ID`';
}
$sql = sprintf('INSERT INTO `country` (%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 '`ISO_CODE`':
$stmt->bindValue($identifier, $this->iso_code, PDO::PARAM_STR);
break;
case '`ISO_SHORT_CODE`':
$stmt->bindValue($identifier, $this->iso_short_code, PDO::PARAM_STR);
break;
case '`DEMONYM`':
$stmt->bindValue($identifier, $this->demonym, PDO::PARAM_STR);
break;
case '`DEFAULT_CURRENCY_ID`':
$stmt->bindValue($identifier, $this->default_currency_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), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例11: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = DetailBarangMasukPeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . DetailBarangMasukPeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(DetailBarangMasukPeer::ID)) {
$modifiedColumns[':p' . $index++] = '`id`';
}
if ($this->isColumnModified(DetailBarangMasukPeer::ID_BARANG_MASUK)) {
$modifiedColumns[':p' . $index++] = '`id_barang_masuk`';
}
if ($this->isColumnModified(DetailBarangMasukPeer::ID_BARANG)) {
$modifiedColumns[':p' . $index++] = '`id_barang`';
}
if ($this->isColumnModified(DetailBarangMasukPeer::HARGA)) {
$modifiedColumns[':p' . $index++] = '`harga`';
}
$sql = sprintf('INSERT INTO `detail_barang_masuk` (%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 '`id_barang_masuk`':
$stmt->bindValue($identifier, $this->id_barang_masuk, PDO::PARAM_INT);
break;
case '`id_barang`':
$stmt->bindValue($identifier, $this->id_barang, PDO::PARAM_INT);
break;
case '`harga`':
$stmt->bindValue($identifier, $this->harga, 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), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例12: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(AidDetailsPeer::ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(AidDetailsPeer::NOM)) {
$modifiedColumns[':p' . $index++] = 'NOM';
}
if ($this->isColumnModified(AidDetailsPeer::NUMERO)) {
$modifiedColumns[':p' . $index++] = 'NUMERO';
}
if ($this->isColumnModified(AidDetailsPeer::INDICE_AID)) {
$modifiedColumns[':p' . $index++] = 'INDICE_AID';
}
if ($this->isColumnModified(AidDetailsPeer::PERSO1)) {
$modifiedColumns[':p' . $index++] = 'PERSO1';
}
if ($this->isColumnModified(AidDetailsPeer::PERSO2)) {
$modifiedColumns[':p' . $index++] = 'PERSO2';
}
if ($this->isColumnModified(AidDetailsPeer::PERSO3)) {
$modifiedColumns[':p' . $index++] = 'PERSO3';
}
if ($this->isColumnModified(AidDetailsPeer::PRODUCTIONS)) {
$modifiedColumns[':p' . $index++] = 'PRODUCTIONS';
}
if ($this->isColumnModified(AidDetailsPeer::RESUME)) {
$modifiedColumns[':p' . $index++] = 'RESUME';
}
if ($this->isColumnModified(AidDetailsPeer::FAMILLE)) {
$modifiedColumns[':p' . $index++] = 'FAMILLE';
}
if ($this->isColumnModified(AidDetailsPeer::MOTS_CLES)) {
$modifiedColumns[':p' . $index++] = 'MOTS_CLES';
}
if ($this->isColumnModified(AidDetailsPeer::ADRESSE1)) {
$modifiedColumns[':p' . $index++] = 'ADRESSE1';
}
if ($this->isColumnModified(AidDetailsPeer::ADRESSE2)) {
$modifiedColumns[':p' . $index++] = 'ADRESSE2';
}
if ($this->isColumnModified(AidDetailsPeer::PUBLIC_DESTINATAIRE)) {
$modifiedColumns[':p' . $index++] = 'PUBLIC_DESTINATAIRE';
}
if ($this->isColumnModified(AidDetailsPeer::CONTACTS)) {
$modifiedColumns[':p' . $index++] = 'CONTACTS';
}
if ($this->isColumnModified(AidDetailsPeer::DIVERS)) {
$modifiedColumns[':p' . $index++] = 'DIVERS';
}
if ($this->isColumnModified(AidDetailsPeer::MATIERE1)) {
$modifiedColumns[':p' . $index++] = 'MATIERE1';
}
if ($this->isColumnModified(AidDetailsPeer::MATIERE2)) {
$modifiedColumns[':p' . $index++] = 'MATIERE2';
}
if ($this->isColumnModified(AidDetailsPeer::ELEVE_PEUT_MODIFIER)) {
$modifiedColumns[':p' . $index++] = 'ELEVE_PEUT_MODIFIER';
}
if ($this->isColumnModified(AidDetailsPeer::PROF_PEUT_MODIFIER)) {
$modifiedColumns[':p' . $index++] = 'PROF_PEUT_MODIFIER';
}
if ($this->isColumnModified(AidDetailsPeer::CPE_PEUT_MODIFIER)) {
$modifiedColumns[':p' . $index++] = 'CPE_PEUT_MODIFIER';
}
if ($this->isColumnModified(AidDetailsPeer::FICHE_PUBLIQUE)) {
$modifiedColumns[':p' . $index++] = 'FICHE_PUBLIQUE';
}
if ($this->isColumnModified(AidDetailsPeer::AFFICHE_ADRESSE1)) {
$modifiedColumns[':p' . $index++] = 'AFFICHE_ADRESSE1';
}
if ($this->isColumnModified(AidDetailsPeer::EN_CONSTRUCTION)) {
$modifiedColumns[':p' . $index++] = 'EN_CONSTRUCTION';
}
$sql = sprintf(
'INSERT INTO aid (%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_STR);
//.........这里部分代码省略.........
示例13: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = PlayerPeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . PlayerPeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(PlayerPeer::ID)) {
$modifiedColumns[':p' . $index++] = '`id`';
}
if ($this->isColumnModified(PlayerPeer::LAST_NAME)) {
$modifiedColumns[':p' . $index++] = '`last_name`';
}
if ($this->isColumnModified(PlayerPeer::FIRST_NAME)) {
$modifiedColumns[':p' . $index++] = '`first_name`';
}
if ($this->isColumnModified(PlayerPeer::PHOTO)) {
$modifiedColumns[':p' . $index++] = '`photo`';
}
if ($this->isColumnModified(PlayerPeer::PHONE)) {
$modifiedColumns[':p' . $index++] = '`phone`';
}
if ($this->isColumnModified(PlayerPeer::MOBILE)) {
$modifiedColumns[':p' . $index++] = '`mobile`';
}
if ($this->isColumnModified(PlayerPeer::NOTE)) {
$modifiedColumns[':p' . $index++] = '`note`';
}
$sql = sprintf('INSERT INTO `player` (%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 '`last_name`':
$stmt->bindValue($identifier, $this->last_name, PDO::PARAM_STR);
break;
case '`first_name`':
$stmt->bindValue($identifier, $this->first_name, PDO::PARAM_STR);
break;
case '`photo`':
$stmt->bindValue($identifier, $this->photo, PDO::PARAM_STR);
break;
case '`phone`':
$stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR);
break;
case '`mobile`':
$stmt->bindValue($identifier, $this->mobile, PDO::PARAM_STR);
break;
case '`note`':
$stmt->bindValue($identifier, $this->note, 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), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例14: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = ClientePeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . ClientePeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(ClientePeer::ID)) {
$modifiedColumns[':p' . $index++] = '`ID`';
}
if ($this->isColumnModified(ClientePeer::NOMBRE)) {
$modifiedColumns[':p' . $index++] = '`NOMBRE`';
}
if ($this->isColumnModified(ClientePeer::CORREO)) {
$modifiedColumns[':p' . $index++] = '`CORREO`';
}
if ($this->isColumnModified(ClientePeer::DIRECCION)) {
$modifiedColumns[':p' . $index++] = '`DIRECCION`';
}
if ($this->isColumnModified(ClientePeer::TELEFONO)) {
$modifiedColumns[':p' . $index++] = '`TELEFONO`';
}
if ($this->isColumnModified(ClientePeer::CIUDAD)) {
$modifiedColumns[':p' . $index++] = '`CIUDAD`';
}
if ($this->isColumnModified(ClientePeer::OBSERVACION)) {
$modifiedColumns[':p' . $index++] = '`OBSERVACION`';
}
if ($this->isColumnModified(ClientePeer::PUNTOS)) {
$modifiedColumns[':p' . $index++] = '`PUNTOS`';
}
if ($this->isColumnModified(ClientePeer::NIT)) {
$modifiedColumns[':p' . $index++] = '`NIT`';
}
$sql = sprintf('INSERT INTO `cliente` (%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 '`NOMBRE`':
$stmt->bindValue($identifier, $this->nombre, PDO::PARAM_STR);
break;
case '`CORREO`':
$stmt->bindValue($identifier, $this->correo, PDO::PARAM_STR);
break;
case '`DIRECCION`':
$stmt->bindValue($identifier, $this->direccion, PDO::PARAM_STR);
break;
case '`TELEFONO`':
$stmt->bindValue($identifier, $this->telefono, PDO::PARAM_STR);
break;
case '`CIUDAD`':
$stmt->bindValue($identifier, $this->ciudad, PDO::PARAM_STR);
break;
case '`OBSERVACION`':
$stmt->bindValue($identifier, $this->observacion, PDO::PARAM_STR);
break;
case '`PUNTOS`':
$stmt->bindValue($identifier, $this->puntos, PDO::PARAM_INT);
break;
case '`NIT`':
$stmt->bindValue($identifier, $this->nit, 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), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
}
示例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 PropelPDO $con A connection object
*
* @return Medicofacturacion A model object, or null if the key is not found
* @throws PropelException
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `idmedicofacturacion`, `idmedico`, `medicofacturacion_razonsocial`, `medicofacturacion_rfc`, `medicofacturacion_calle`, `medicofacturacion_noexterior`, `medicofacturacion_nointerior`, `medicofacturacion_colonia`, `medicofacturacion_ciudad`, `medicofacturacion_estado`, `medicofacturacion_pais`, `medicofacturacion_codigopostal`, `medicofacturacion_telefono`, `medicofacturacion_email` FROM `medicofacturacion` WHERE `idmedicofacturacion` = :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), $e);
}
$obj = null;
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$obj = new Medicofacturacion();
$obj->hydrate($row);
MedicofacturacionPeer::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}