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


PHP Connection::convertToPHPValue方法代码示例

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


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

示例1: read

 /**
  * read $columns from $table_name
  * @param array $columns
  * @param array $filters
  * @param array $limit
  * @param array $order_by
  * @param string $return_type
  * @return array:
  */
 public function read(array $columns = [], array $filters = [], array $limit = [], array $order_by = [], $return_type = self::READ_RETURN_COMPLEX)
 {
     $return = [];
     $alias_mapping = [];
     $qb = $this->conn->createQueryBuilder();
     if (empty($columns)) {
         $columns = $this->getColumnNames();
     }
     foreach ($columns as $column) {
         $column_name = null;
         $alias = null;
         $expr = [];
         if (is_string($column)) {
             $column_name = $alias = $column;
             if (strpos($alias, ':') !== false) {
                 $alias = explode(':', $alias);
                 $alias = array_pop($alias);
             }
         } elseif (is_array($column)) {
             list($column_name, $alias) = $column;
         }
         if (strpos($column_name, ':') !== false) {
             $expr = explode(':', $column_name);
             $column_name = array_pop($expr);
         }
         $alias_mapping[$alias] = $column_name;
         if ($this->getColumn($column_name) === null) {
             throw Schema\SchemaException::columnDoesNotExist($column_name, $this->table_name);
         }
         $column_expr = $this->conn->quoteIdentifier($column_name);
         $expr = array_reverse($expr);
         foreach ($expr as $ex) {
             if (in_array($ex, ['max', 'min', 'avg', 'count', 'sum', 'lower', 'upper'])) {
                 $column_expr = call_user_func([$this->conn->getDatabasePlatform(), 'get' . ucfirst($ex) . 'Expression'], $column_expr);
             } else {
                 throw QueryBuilderException::expressionTypeDoesNotExist($ex);
             }
         }
         if ($column_name !== $alias || !empty($expr)) {
             $column_expr .= ' AS ' . $this->conn->quoteIdentifier($alias);
         }
         $qb->addSelect($column_expr);
     }
     $qb->from($this->quoted_table_name);
     $this->buildWhere($qb, $filters)->buildOrderBy($qb, $order_by)->buildLimit($qb, $limit);
     $res = $qb->execute();
     $return = $res->fetchAll(\PDO::FETCH_ASSOC);
     if (in_array($return_type, [self::READ_RETURN_SIMPLE, self::READ_RETURN_COMPLEX])) {
         foreach ($return as $index => $row) {
             foreach ($row as $column => $value) {
                 if ($return_type === self::READ_RETURN_SIMPLE && !$this->isSimpleType($alias_mapping[$column])) {
                     continue;
                 }
                 $return[$index][$column] = $this->conn->convertToPHPValue($value, $this->column_types[$alias_mapping[$column]]);
             }
         }
     }
     return $return;
 }
开发者ID:schwaen,项目名称:doctrine-dbal-extensions,代码行数:68,代码来源:Model.php

示例2: execute

 /**
  * {@inheritdoc}
  */
 public function execute(LoggerInterface $logger)
 {
     // update field itself
     $sql = "UPDATE oro_entity_config_index_value\n            SET value = ?\n            WHERE\n                entity_id = (SELECT id FROM oro_entity_config WHERE class_name = ? LIMIT 1) AND\n                field_id IS NULL AND\n                scope = ? AND\n                code = ?\n            ";
     $parameters = [$this->value, $this->entityName, $this->scope, $this->code];
     $statement = $this->connection->prepare($sql);
     $statement->execute($parameters);
     $this->logQuery($logger, $sql, $parameters);
     $logger->debug($sql);
     // update entity config cached data
     $sql = 'SELECT data FROM oro_entity_config WHERE class_name = ? LIMIT 1';
     $parameters = [$this->entityName];
     $data = $this->connection->fetchColumn($sql, $parameters);
     $this->logQuery($logger, $sql, $parameters);
     $data = $data ? $this->connection->convertToPHPValue($data, Type::TARRAY) : [];
     $data[$this->scope][$this->code] = $this->value;
     $data = $this->connection->convertToDatabaseValue($data, Type::TARRAY);
     $sql = 'UPDATE oro_entity_config SET data = ? WHERE class_name = ?';
     $parameters = [$data, $this->entityName];
     $statement = $this->connection->prepare($sql);
     $statement->execute($parameters);
     $this->logQuery($logger, $sql, $parameters);
 }
开发者ID:Maksold,项目名称:platform,代码行数:26,代码来源:UpdateEntityConfigEntityValueQuery.php

示例3: selectOneSQL

 /**
  * Select a single entity matching an SQL query. If more than one
  * row is matched by the query, only the first entity will be
  * returned.
  *
  * @param Connection $connection    A connection instance
  * @param string     $sql           The SQL query
  * @param array      $parameters    Any bound parameters required for the query
  * @param array      $field_mapping An array of result columns => entity fields
  *
  * @return Entity|null The selected Entity, or null if no entity was found
  */
 public static function selectOneSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
 {
     $stmt = $connection->prepare($sql);
     $stmt->execute($parameters);
     $result = $stmt->fetch();
     if ($result) {
         foreach ($field_mapping as $result_column => $entity_field) {
             if (!isset($result[$result_column])) {
                 continue;
             }
             $result[$entity_field] = $result[$result_column];
             unset($result[$result_column]);
         }
         foreach (static::$types as $column => $type) {
             if (isset($result[$column])) {
                 $result[$column] = $connection->convertToPHPValue($result[$column], $type);
             }
         }
         $entity = new static($connection, $result);
         return $entity->setStored();
     }
     return null;
 }
开发者ID:glynnforrest,项目名称:active-doctrine,代码行数:35,代码来源:Entity.php


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