当前位置: 首页>>代码示例>>PHP>>正文


PHP ConnectionInterface::query方法代码示例

本文整理汇总了PHP中Propel\Runtime\Connection\ConnectionInterface::query方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionInterface::query方法的具体用法?PHP ConnectionInterface::query怎么用?PHP ConnectionInterface::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Propel\Runtime\Connection\ConnectionInterface的用法示例。


在下文中一共展示了ConnectionInterface::query方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGeneratePostActivation

 public function testGeneratePostActivation()
 {
     // Touch a new "insert.sql" file and copy a "create.sql" file
     /** @var \org\bovigo\vfs\vfsStreamFile $file */
     $configDir = $this->stream->getChild("Config");
     $file = vfsStream::newFile("create.sql")->at($configDir);
     $file->setContent(file_get_contents(__DIR__ . "/../" . static::TEST_MODULE_PATH . "Config" . DS . "thelia.sql"));
     vfsStream::newFile("insert.sql")->at($configDir);
     // Then run the generator
     $generator = new ModulePhpGenerator($this->getSmarty());
     $generator->doGenerate($this->event);
     // Read the class
     include $this->getStreamPath("TheliaStudioTestModule.php");
     $reflection = new \ReflectionClass("TheliaStudioTestModule\\TheliaStudioTestModule");
     $this->assertTrue($reflection->hasConstant("MESSAGE_DOMAIN"));
     $this->assertEquals("theliastudiotestmodule", $reflection->getConstant("MESSAGE_DOMAIN"));
     $this->assertTrue($reflection->hasMethod("postActivation"));
     // get a method closure
     $method = $reflection->getMethod("postActivation");
     $closure = $method->getClosure($reflection->newInstance());
     // Test that the table doesn't exist
     /** @var \Propel\Runtime\DataFetcher\PDODataFetcher $stmt */
     $stmt = $this->con->query("SHOW TABLES LIKE 'example_table'");
     $this->assertEquals(0, $stmt->count());
     // Execute the method
     $closure($this->con);
     // Now it exists
     /** @var \Propel\Runtime\DataFetcher\PDODataFetcher $stmt */
     $stmt = $this->con->query("SHOW TABLES LIKE 'example_table'");
     $this->assertEquals(1, $stmt->count());
 }
开发者ID:Alban-io,项目名称:TheliaStudio,代码行数:31,代码来源:ModulePhpGeneratorTest.php

示例2: testCreateSqlRuleGeneration

 public function testCreateSqlRuleGeneration()
 {
     $generator = new RuleGenerator();
     $generator->doGenerate($this->event);
     // Test file generation
     $this->assertFileExists($createFile = $this->getStreamPath("Config/create.sql"));
     // Test that the table doesn't exist
     /** @var \Propel\Runtime\DataFetcher\PDODataFetcher $stmt */
     $stmt = $this->con->query("SHOW TABLES LIKE 'example_table'");
     $this->assertEquals(0, $stmt->count());
     // Test that the file has the correct behavior
     $db = new Database($this->con);
     $db->insertSql(null, [$createFile]);
     // Now it exists
     /** @var \Propel\Runtime\DataFetcher\PDODataFetcher $stmt */
     $stmt = $this->con->query("SHOW TABLES LIKE 'example_table'");
     $this->assertEquals(1, $stmt->count());
     // Insert a new value in the table
     $this->con->exec("INSERT INTO `example_table`(`visible`, `position`) VALUES(1, 42)");
     // Check that the value exists
     $stmt = $this->con->query("SELECT * FROM `example_table`");
     $this->assertEquals(1, $stmt->count());
     // Then test that it doesn't crash if we apply the script again
     $db = new Database($this->con);
     $db->insertSql(null, [$createFile]);
     // Check that the previous entry still exists ( proves that there is no DROP TABLE )
     $stmt = $this->con->query("SELECT * FROM `example_table`");
     $fetched = $stmt->fetch(\PDO::FETCH_ASSOC);
     $this->assertTrue(is_array($fetched));
     $this->assertArrayHasKey("position", $fetched);
     $this->assertArrayHasKey("visible", $fetched);
     $this->assertEquals("1", $fetched["visible"]);
     $this->assertEquals("42", $fetched["position"]);
 }
开发者ID:Alban-io,项目名称:TheliaStudio,代码行数:34,代码来源:RuleGeneratorTest.php

示例3: getId

 /**
  * Gets ID for specified sequence name.
  *
  * @param ConnectionInterface $con
  * @param string              $name
  *
  * @return integer
  */
 public function getId(ConnectionInterface $con, $name = null)
 {
     if (null === $name) {
         throw new InvalidArgumentException("Unable to fetch next sequence ID without sequence name.");
     }
     $dataFetcher = $con->query(sprintf('SELECT nextval(%s)', $con->quote($name)));
     return $dataFetcher->fetchColumn();
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:16,代码来源:PgsqlAdapter.php

示例4: getId

 /**
  * Gets ID for specified sequence name.
  *
  * @param     ConnectionInterface $con
  * @param     string  $name
  *
  * @return    integer
  */
 public function getId(ConnectionInterface $con, $name = null)
 {
     if ($name === null) {
         throw new InvalidArgumentException("Unable to fetch next sequence ID without sequence name.");
     }
     $stmt = $con->query("SELECT nextval(" . $con->quote($name) . ")");
     $row = $stmt->fetch(PDO::FETCH_NUM);
     return $row[0];
 }
开发者ID:rozwell,项目名称:Propel2,代码行数:17,代码来源:PgsqlAdapter.php

示例5: initConnection

 public function initConnection(ConnectionInterface $con, array $settings)
 {
     $con->query('PRAGMA foreign_keys = ON');
     parent::initConnection($con, $settings);
     //add regex support
     $con->sqliteCreateFunction('regexp', function ($pattern, $value) {
         mb_regex_encoding('UTF-8');
         return false !== mb_ereg($pattern, $value) ? 1 : 0;
     });
 }
开发者ID:bondarovich,项目名称:Propel2,代码行数:10,代码来源:SqliteAdapter.php

示例6: getId

 /**
  * @param     ConnectionInterface $con
  * @param     string  $name
  *
  * @throws    PropelException
  * @return    integer
  */
 public function getId(ConnectionInterface $con, $name = null)
 {
     if ($name === null) {
         throw new PropelException("Unable to fetch next sequence ID without sequence name.");
     }
     $stmt = $con->query("SELECT " . $name . ".nextval FROM dual");
     $row = $stmt->fetch(PDO::FETCH_NUM);
     return $row[0];
 }
开发者ID:norfil,项目名称:Propel2,代码行数:16,代码来源:OracleAdapter.php

示例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[UserTableMap::COL_ID] = true;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserTableMap::COL_ID . ')');
     }
     if (null === $this->id) {
         try {
             $dataFetcher = $con->query("SELECT nextval('system_user_id_seq')");
             $this->id = $dataFetcher->fetchColumn();
         } catch (Exception $e) {
             throw new PropelException('Unable to get sequence id.', 0, $e);
         }
     }
     // 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_NAME)) {
         $modifiedColumns[':p' . $index++] = 'name';
     }
     if ($this->isColumnModified(UserTableMap::COL_EMAIL)) {
         $modifiedColumns[':p' . $index++] = 'email';
     }
     if ($this->isColumnModified(UserTableMap::COL_PASSWORD)) {
         $modifiedColumns[':p' . $index++] = 'password';
     }
     if ($this->isColumnModified(UserTableMap::COL_SCORE)) {
         $modifiedColumns[':p' . $index++] = 'score';
     }
     $sql = sprintf('INSERT INTO system_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 'name':
                     $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
                     break;
                 case 'email':
                     $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR);
                     break;
                 case 'password':
                     $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR);
                     break;
                 case 'score':
                     $stmt->bindValue($identifier, $this->score, 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);
     }
     $this->setNew(false);
 }
开发者ID:amandaaurita,项目名称:hackapuc2015,代码行数:69,代码来源:User.php

示例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[OrderTableMap::COL_ID] = true;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderTableMap::COL_ID . ')');
     }
     if (null === $this->id) {
         try {
             $dataFetcher = $con->query("SELECT nextval('orders_id_seq')");
             $this->id = $dataFetcher->fetchColumn();
         } catch (Exception $e) {
             throw new PropelException('Unable to get sequence id.', 0, $e);
         }
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(OrderTableMap::COL_ID)) {
         $modifiedColumns[':p' . $index++] = 'id';
     }
     if ($this->isColumnModified(OrderTableMap::COL_TRUCK_ID)) {
         $modifiedColumns[':p' . $index++] = 'truck_id';
     }
     if ($this->isColumnModified(OrderTableMap::COL_ITEM_NAME)) {
         $modifiedColumns[':p' . $index++] = 'item_name';
     }
     if ($this->isColumnModified(OrderTableMap::COL_PRICE)) {
         $modifiedColumns[':p' . $index++] = 'price';
     }
     if ($this->isColumnModified(OrderTableMap::COL_CHARGE_ID)) {
         $modifiedColumns[':p' . $index++] = 'charge_id';
     }
     if ($this->isColumnModified(OrderTableMap::COL_CUSTOMER_ID)) {
         $modifiedColumns[':p' . $index++] = 'customer_id';
     }
     if ($this->isColumnModified(OrderTableMap::COL_CUSTOMER_NAME)) {
         $modifiedColumns[':p' . $index++] = 'customer_name';
     }
     if ($this->isColumnModified(OrderTableMap::COL_CUSTOMER_EMAIL)) {
         $modifiedColumns[':p' . $index++] = 'customer_email';
     }
     if ($this->isColumnModified(OrderTableMap::COL_CUSTOMER_PHONE_NUMBER)) {
         $modifiedColumns[':p' . $index++] = 'customer_phone_number';
     }
     if ($this->isColumnModified(OrderTableMap::COL_OPEN)) {
         $modifiedColumns[':p' . $index++] = 'open';
     }
     if ($this->isColumnModified(OrderTableMap::COL_CREATED_AT)) {
         $modifiedColumns[':p' . $index++] = 'created_at';
     }
     if ($this->isColumnModified(OrderTableMap::COL_UPDATED_AT)) {
         $modifiedColumns[':p' . $index++] = 'updated_at';
     }
     $sql = sprintf('INSERT INTO orders (%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 'truck_id':
                     $stmt->bindValue($identifier, $this->truck_id, PDO::PARAM_INT);
                     break;
                 case 'item_name':
                     $stmt->bindValue($identifier, $this->item_name, PDO::PARAM_STR);
                     break;
                 case 'price':
                     $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR);
                     break;
                 case 'charge_id':
                     $stmt->bindValue($identifier, $this->charge_id, PDO::PARAM_STR);
                     break;
                 case 'customer_id':
                     $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_STR);
                     break;
                 case 'customer_name':
                     $stmt->bindValue($identifier, $this->customer_name, PDO::PARAM_STR);
                     break;
                 case 'customer_email':
                     $stmt->bindValue($identifier, $this->customer_email, PDO::PARAM_STR);
                     break;
                 case 'customer_phone_number':
                     $stmt->bindValue($identifier, $this->customer_phone_number, PDO::PARAM_STR);
                     break;
                 case 'open':
                     $stmt->bindValue($identifier, $this->open, PDO::PARAM_BOOL);
                     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':
//.........这里部分代码省略.........
开发者ID:hackathon-5,项目名称:power-ragers-repo,代码行数:101,代码来源:Order.php

示例9: 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[PayPalIpnLogTableMap::COL_ID] = true;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . PayPalIpnLogTableMap::COL_ID . ')');
     }
     if (null === $this->id) {
         try {
             $dataFetcher = $con->query("SELECT nextval('paypal_ipn_log_id_seq')");
             $this->id = $dataFetcher->fetchColumn();
         } catch (Exception $e) {
             throw new PropelException('Unable to get sequence id.', 0, $e);
         }
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(PayPalIpnLogTableMap::COL_ID)) {
         $modifiedColumns[':p' . $index++] = 'ID';
     }
     if ($this->isColumnModified(PayPalIpnLogTableMap::COL_LOG)) {
         $modifiedColumns[':p' . $index++] = 'LOG';
     }
     if ($this->isColumnModified(PayPalIpnLogTableMap::COL_CREATED_AT)) {
         $modifiedColumns[':p' . $index++] = 'CREATED_AT';
     }
     if ($this->isColumnModified(PayPalIpnLogTableMap::COL_UPDATED_AT)) {
         $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
     }
     $sql = sprintf('INSERT INTO paypal_ipn_log (%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 'LOG':
                     $stmt->bindValue($identifier, $this->log, 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);
     }
     $this->setNew(false);
 }
开发者ID:Junyue,项目名称:zidisha2,代码行数:63,代码来源:PayPalIpnLog.php

示例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[StripeTransactionTableMap::COL_ID] = true;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . StripeTransactionTableMap::COL_ID . ')');
     }
     if (null === $this->id) {
         try {
             $dataFetcher = $con->query("SELECT nextval('stripe_transactions_id_seq')");
             $this->id = $dataFetcher->fetchColumn();
         } catch (Exception $e) {
             throw new PropelException('Unable to get sequence id.', 0, $e);
         }
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(StripeTransactionTableMap::COL_ID)) {
         $modifiedColumns[':p' . $index++] = 'ID';
     }
     if ($this->isColumnModified(StripeTransactionTableMap::COL_STRIPE_ID)) {
         $modifiedColumns[':p' . $index++] = 'STRIPE_ID';
     }
     if ($this->isColumnModified(StripeTransactionTableMap::COL_AMOUNT)) {
         $modifiedColumns[':p' . $index++] = 'AMOUNT';
     }
     if ($this->isColumnModified(StripeTransactionTableMap::COL_DONATION_AMOUNT)) {
         $modifiedColumns[':p' . $index++] = 'DONATION_AMOUNT';
     }
     if ($this->isColumnModified(StripeTransactionTableMap::COL_TRANSACTION_FEE)) {
         $modifiedColumns[':p' . $index++] = 'TRANSACTION_FEE';
     }
     if ($this->isColumnModified(StripeTransactionTableMap::COL_TOTAL_AMOUNT)) {
         $modifiedColumns[':p' . $index++] = 'TOTAL_AMOUNT';
     }
     if ($this->isColumnModified(StripeTransactionTableMap::COL_STATUS)) {
         $modifiedColumns[':p' . $index++] = 'STATUS';
     }
     if ($this->isColumnModified(StripeTransactionTableMap::COL_PAYMENT_ID)) {
         $modifiedColumns[':p' . $index++] = 'PAYMENT_ID';
     }
     if ($this->isColumnModified(StripeTransactionTableMap::COL_CREATED_AT)) {
         $modifiedColumns[':p' . $index++] = 'CREATED_AT';
     }
     if ($this->isColumnModified(StripeTransactionTableMap::COL_UPDATED_AT)) {
         $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
     }
     $sql = sprintf('INSERT INTO stripe_transactions (%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 'STRIPE_ID':
                     $stmt->bindValue($identifier, $this->stripe_id, PDO::PARAM_STR);
                     break;
                 case 'AMOUNT':
                     $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR);
                     break;
                 case 'DONATION_AMOUNT':
                     $stmt->bindValue($identifier, $this->donation_amount, PDO::PARAM_STR);
                     break;
                 case 'TRANSACTION_FEE':
                     $stmt->bindValue($identifier, $this->transaction_fee, PDO::PARAM_STR);
                     break;
                 case 'TOTAL_AMOUNT':
                     $stmt->bindValue($identifier, $this->total_amount, PDO::PARAM_STR);
                     break;
                 case 'STATUS':
                     $stmt->bindValue($identifier, $this->status, PDO::PARAM_STR);
                     break;
                 case 'PAYMENT_ID':
                     $stmt->bindValue($identifier, $this->payment_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);
     }
     $this->setNew(false);
 }
开发者ID:Junyue,项目名称:zidisha2,代码行数:99,代码来源:StripeTransaction.php

示例11: initConnection

 public function initConnection(ConnectionInterface $con, array $settings)
 {
     $con->query('PRAGMA foreign_keys = ON');
     parent::initConnection($con, $settings);
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:5,代码来源:SqliteAdapter.php

示例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[ParticipantTableMap::COL_ID] = true;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . ParticipantTableMap::COL_ID . ')');
     }
     if (null === $this->id) {
         try {
             $dataFetcher = $con->query("SELECT nextval('participant_id_seq')");
             $this->id = $dataFetcher->fetchColumn();
         } catch (Exception $e) {
             throw new PropelException('Unable to get sequence id.', 0, $e);
         }
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(ParticipantTableMap::COL_ID)) {
         $modifiedColumns[':p' . $index++] = 'id';
     }
     if ($this->isColumnModified(ParticipantTableMap::COL_NAME)) {
         $modifiedColumns[':p' . $index++] = 'name';
     }
     if ($this->isColumnModified(ParticipantTableMap::COL_COUNTRY_CODE)) {
         $modifiedColumns[':p' . $index++] = 'country_code';
     }
     if ($this->isColumnModified(ParticipantTableMap::COL_IS_WINNER)) {
         $modifiedColumns[':p' . $index++] = 'is_winner';
     }
     if ($this->isColumnModified(ParticipantTableMap::COL_GAME_ID)) {
         $modifiedColumns[':p' . $index++] = 'game_id';
     }
     $sql = sprintf('INSERT INTO participant (%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 'country_code':
                     $stmt->bindValue($identifier, $this->country_code, PDO::PARAM_STR);
                     break;
                 case 'is_winner':
                     $stmt->bindValue($identifier, $this->is_winner, PDO::PARAM_BOOL);
                     break;
                 case 'game_id':
                     $stmt->bindValue($identifier, $this->game_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);
     }
     $this->setNew(false);
 }
开发者ID:amandaaurita,项目名称:hackapuc2015,代码行数:69,代码来源:Participant.php

示例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[GameTableMap::COL_ID] = true;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . GameTableMap::COL_ID . ')');
     }
     if (null === $this->id) {
         try {
             $dataFetcher = $con->query("SELECT nextval('game_id_seq')");
             $this->id = $dataFetcher->fetchColumn();
         } catch (Exception $e) {
             throw new PropelException('Unable to get sequence id.', 0, $e);
         }
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(GameTableMap::COL_ID)) {
         $modifiedColumns[':p' . $index++] = 'id';
     }
     if ($this->isColumnModified(GameTableMap::COL_MODALITY)) {
         $modifiedColumns[':p' . $index++] = 'modality';
     }
     if ($this->isColumnModified(GameTableMap::COL_RESULT)) {
         $modifiedColumns[':p' . $index++] = 'result';
     }
     if ($this->isColumnModified(GameTableMap::COL_BET_COST)) {
         $modifiedColumns[':p' . $index++] = 'bet_cost';
     }
     if ($this->isColumnModified(GameTableMap::COL_START)) {
         $modifiedColumns[':p' . $index++] = 'start';
     }
     if ($this->isColumnModified(GameTableMap::COL_FINISH)) {
         $modifiedColumns[':p' . $index++] = 'finish';
     }
     $sql = sprintf('INSERT INTO game (%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 'modality':
                     $stmt->bindValue($identifier, $this->modality, PDO::PARAM_STR);
                     break;
                 case 'result':
                     $stmt->bindValue($identifier, $this->result, PDO::PARAM_STR);
                     break;
                 case 'bet_cost':
                     $stmt->bindValue($identifier, $this->bet_cost, PDO::PARAM_INT);
                     break;
                 case 'start':
                     $stmt->bindValue($identifier, $this->start ? $this->start->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                     break;
                 case 'finish':
                     $stmt->bindValue($identifier, $this->finish ? $this->finish->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);
     }
     $this->setNew(false);
 }
开发者ID:amandaaurita,项目名称:hackapuc2015,代码行数:75,代码来源:Game.php


注:本文中的Propel\Runtime\Connection\ConnectionInterface::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。