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


PHP ConnectionInterface::prepare方法代码示例

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


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

示例1: applyXml

 /**
  * @param string $xml
  *
  * @return Database|boolean
  */
 public function applyXml($xml, $changeRequired = false)
 {
     $this->readDatabase();
     $builder = new QuickBuilder();
     $builder->setIdentifierQuoting(true);
     $builder->setPlatform($this->database->getPlatform());
     $builder->setSchema($xml);
     $database = $builder->getDatabase();
     $database->setSchema('migration');
     $database->setPlatform($this->database->getPlatform());
     $diff = DatabaseComparator::computeDiff($this->database, $database);
     if (false === $diff) {
         if ($changeRequired) {
             throw new BuildException(sprintf("No changes in schema to current database: \nSchema database:\n%s\n\nCurrent Database:\n%s", $database, $this->database));
         }
         return false;
     }
     $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
     $this->con->beginTransaction();
     if (!$sql) {
         throw new BuildException(sprintf('Ooops. There is a diff between current database and schema xml but no SQL has been generated. Change: %s', $diff));
     }
     $statements = SqlParser::parseString($sql);
     foreach ($statements as $statement) {
         try {
             $stmt = $this->con->prepare($statement);
             $stmt->execute();
         } catch (\Exception $e) {
             throw new BuildException(sprintf("Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n", $statement, $this->database, $database), null, $e);
         }
     }
     $this->con->commit();
     return $database;
 }
开发者ID:disider,项目名称:Propel2,代码行数:39,代码来源:MigrationTestCase.php

示例2: applyXml

 /**
  * @param string $xml
  *
  * @return Database
  */
 public function applyXml($xml)
 {
     $this->readDatabase();
     $builder = new QuickBuilder();
     $builder->setPlatform($this->database->getPlatform());
     $builder->setSchema($xml);
     $database = $builder->getDatabase();
     $database->setSchema('migration');
     $database->setPlatform($this->database->getPlatform());
     $diff = DatabaseComparator::computeDiff($this->database, $database);
     if (false === $diff) {
         return null;
     }
     $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
     $this->con->beginTransaction();
     $statements = SqlParser::parseString($sql);
     foreach ($statements as $statement) {
         try {
             $stmt = $this->con->prepare($statement);
             $stmt->execute();
         } catch (\Exception $e) {
             $this->con->rollBack();
             throw new BuildException(sprintf("Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n", $statement, $this->database, $database), null, $e);
         }
     }
     $this->con->commit();
     return $database;
 }
开发者ID:a-melnichuk,项目名称:Movies-Demo,代码行数:33,代码来源:MigrationTestCase.php

示例3: executeStatements

 /**
  * Execute a list of DDL statements based on an array
  * Does not use transactions since they are not supported in DDL statements
  *
  * @param array               $statements a list of SQL statements
  * @param ConnectionInterface $connection a connection object
  *
  * @return integer the number of executed statements
  */
 protected static function executeStatements($statements, ConnectionInterface $connection)
 {
     $executed = 0;
     foreach ($statements as $statement) {
         $stmt = $connection->prepare($statement);
         if ($stmt instanceof StatementInterface) {
             // only execute if has no error
             $stmt->execute();
             $executed++;
         }
     }
     return $executed;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:22,代码来源:SqlParser.php

示例4: updateSchema

 /**
  * Detects the differences between current connected database and $pDatabase
  * and updates the schema. This does not DROP tables.
  *
  * @param Database $pDatabase
  */
 public function updateSchema($pDatabase)
 {
     $diff = DatabaseComparator::computeDiff($this->database, $pDatabase);
     $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
     $statements = SqlParser::parseString($sql);
     foreach ($statements as $statement) {
         if (strpos($statement, 'DROP') === 0) {
             // drop statements cause errors since the table doesn't exist
             continue;
         }
         $stmt = $this->con->prepare($statement);
         $stmt->execute();
     }
 }
开发者ID:bondarovich,项目名称:Propel2,代码行数:20,代码来源:PlatformDatabaseBuildTimeBase.php

示例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[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);
 }
开发者ID:mtornero,项目名称:slowshop,代码行数:73,代码来源:WishlistProduct.php

示例6: 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;
 }
开发者ID:Tekstove,项目名称:Tekstove-api,代码行数:33,代码来源:PermissionGroupUserQuery.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;
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(MenuI18nVersionTableMap::ID)) {
         $modifiedColumns[':p' . $index++] = 'ID';
     }
     if ($this->isColumnModified(MenuI18nVersionTableMap::LOCALE)) {
         $modifiedColumns[':p' . $index++] = 'LOCALE';
     }
     if ($this->isColumnModified(MenuI18nVersionTableMap::TITLE)) {
         $modifiedColumns[':p' . $index++] = 'TITLE';
     }
     if ($this->isColumnModified(MenuI18nVersionTableMap::DESCRIPTION)) {
         $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
     }
     if ($this->isColumnModified(MenuI18nVersionTableMap::CHAPO)) {
         $modifiedColumns[':p' . $index++] = 'CHAPO';
     }
     if ($this->isColumnModified(MenuI18nVersionTableMap::POSTSCRIPTUM)) {
         $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
     }
     if ($this->isColumnModified(MenuI18nVersionTableMap::CREATED_AT)) {
         $modifiedColumns[':p' . $index++] = 'CREATED_AT';
     }
     if ($this->isColumnModified(MenuI18nVersionTableMap::UPDATED_AT)) {
         $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
     }
     if ($this->isColumnModified(MenuI18nVersionTableMap::VERSION)) {
         $modifiedColumns[':p' . $index++] = 'VERSION';
     }
     if ($this->isColumnModified(MenuI18nVersionTableMap::VERSION_CREATED_AT)) {
         $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
     }
     if ($this->isColumnModified(MenuI18nVersionTableMap::VERSION_CREATED_BY)) {
         $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
     }
     $sql = sprintf('INSERT INTO menu_i18n_version (%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;
                 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);
     }
     $this->setNew(false);
 }
开发者ID:AnthonyMeedle,项目名称:thelia-v2-module-Menu,代码行数:93,代码来源:MenuI18nVersion.php

示例8: 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;
 }
开发者ID:scornfield,项目名称:StrayAdmin,代码行数:32,代码来源:PlayersOldQuery.php

示例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   ChildCouponCountry A model object, or null if the key is not found
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `COUPON_ID`, `COUNTRY_ID` FROM `coupon_country` WHERE `COUPON_ID` = :p0 AND `COUNTRY_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)) {
         $obj = new ChildCouponCountry();
         $obj->hydrate($row);
         CouponCountryTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
     }
     $stmt->closeCursor();
     return $obj;
 }
开发者ID:margery,项目名称:thelia,代码行数:30,代码来源:CouponCountryQuery.php

示例10: 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 ChildTranslationCatalog A model object, or null if the key is not found
  */
 protected function findPkSimple($key, ConnectionInterface $con)
 {
     $sql = 'SELECT id, application_id, name, created_at, updated_at FROM translation_catalog 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 ChildTranslationCatalog $obj */
         $obj = new ChildTranslationCatalog();
         $obj->hydrate($row);
         TranslationCatalogTableMap::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }
开发者ID:nstojanovickg,项目名称:diplomski,代码行数:32,代码来源:TranslationCatalogQuery.php

示例11: 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(CouponVersionTableMap::ID)) {
         $modifiedColumns[':p' . $index++] = '`ID`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::CODE)) {
         $modifiedColumns[':p' . $index++] = '`CODE`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::TYPE)) {
         $modifiedColumns[':p' . $index++] = '`TYPE`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_EFFECTS)) {
         $modifiedColumns[':p' . $index++] = '`SERIALIZED_EFFECTS`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) {
         $modifiedColumns[':p' . $index++] = '`IS_ENABLED`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::START_DATE)) {
         $modifiedColumns[':p' . $index++] = '`START_DATE`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) {
         $modifiedColumns[':p' . $index++] = '`EXPIRATION_DATE`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) {
         $modifiedColumns[':p' . $index++] = '`MAX_USAGE`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) {
         $modifiedColumns[':p' . $index++] = '`IS_CUMULATIVE`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) {
         $modifiedColumns[':p' . $index++] = '`IS_REMOVING_POSTAGE`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) {
         $modifiedColumns[':p' . $index++] = '`IS_AVAILABLE_ON_SPECIAL_OFFERS`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) {
         $modifiedColumns[':p' . $index++] = '`IS_USED`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_CONDITIONS)) {
         $modifiedColumns[':p' . $index++] = '`SERIALIZED_CONDITIONS`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::PER_CUSTOMER_USAGE_COUNT)) {
         $modifiedColumns[':p' . $index++] = '`PER_CUSTOMER_USAGE_COUNT`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) {
         $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::UPDATED_AT)) {
         $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::VERSION)) {
         $modifiedColumns[':p' . $index++] = '`VERSION`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::VERSION_CREATED_AT)) {
         $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
     }
     if ($this->isColumnModified(CouponVersionTableMap::VERSION_CREATED_BY)) {
         $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
     }
     $sql = sprintf('INSERT INTO `coupon_version` (%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 '`CODE`':
                     $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
                     break;
                 case '`TYPE`':
                     $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
                     break;
                 case '`SERIALIZED_EFFECTS`':
                     $stmt->bindValue($identifier, $this->serialized_effects, PDO::PARAM_STR);
                     break;
                 case '`IS_ENABLED`':
                     $stmt->bindValue($identifier, (int) $this->is_enabled, PDO::PARAM_INT);
                     break;
                 case '`START_DATE`':
                     $stmt->bindValue($identifier, $this->start_date ? $this->start_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                     break;
                 case '`EXPIRATION_DATE`':
                     $stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                     break;
                 case '`MAX_USAGE`':
                     $stmt->bindValue($identifier, $this->max_usage, PDO::PARAM_INT);
                     break;
                 case '`IS_CUMULATIVE`':
//.........这里部分代码省略.........
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:101,代码来源:CouponVersion.php

示例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   ChildCustomerTitleI18n A model object, or null if the key is not found
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `ID`, `LOCALE`, `SHORT`, `LONG` FROM `customer_title_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
         $stmt->bindValue(':p1', $key[1], 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 ChildCustomerTitleI18n();
         $obj->hydrate($row);
         CustomerTitleI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
     }
     $stmt->closeCursor();
     return $obj;
 }
开发者ID:margery,项目名称:thelia,代码行数:30,代码来源:CustomerTitleI18nQuery.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[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);
 }
开发者ID:alejandrososa,项目名称:angularja,代码行数:55,代码来源:JaCategorias.php

示例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   ChildProductVersion A model object, or null if the key is not found
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `VIRTUAL`, `VISIBLE`, `POSITION`, `TEMPLATE_ID`, `BRAND_ID`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `product_version` WHERE `ID` = :p0 AND `VERSION` = :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)) {
         $obj = new ChildProductVersion();
         $obj->hydrate($row);
         ProductVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
     }
     $stmt->closeCursor();
     return $obj;
 }
开发者ID:alex63530,项目名称:thelia,代码行数:30,代码来源:ProductVersionQuery.php

示例15: 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(CustomerTitleI18nTableMap::ID)) {
         $modifiedColumns[':p' . $index++] = '`ID`';
     }
     if ($this->isColumnModified(CustomerTitleI18nTableMap::LOCALE)) {
         $modifiedColumns[':p' . $index++] = '`LOCALE`';
     }
     if ($this->isColumnModified(CustomerTitleI18nTableMap::SHORT)) {
         $modifiedColumns[':p' . $index++] = '`SHORT`';
     }
     if ($this->isColumnModified(CustomerTitleI18nTableMap::LONG)) {
         $modifiedColumns[':p' . $index++] = '`LONG`';
     }
     $sql = sprintf('INSERT INTO `customer_title_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 '`SHORT`':
                     $stmt->bindValue($identifier, $this->short, PDO::PARAM_STR);
                     break;
                 case '`LONG`':
                     $stmt->bindValue($identifier, $this->long, 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:shirone,项目名称:thelia,代码行数:51,代码来源:CustomerTitleI18n.php


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