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


PHP Connection::fetchColumn方法代码示例

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


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

示例1: doStart

 protected function doStart($parentId)
 {
     $this->conn->beginTransaction();
     $platform = $this->conn->getDatabasePlatform();
     $variables = $this->variables;
     $executionNextPollDate = null;
     if (isset($variables['batchWaitInterval'])) {
         if (!$variables['batchWaitInterval'] instanceof \DateInterval) {
             throw new \ezcWorkflowExecutionException("Specified batch waiting interval has to be instance of DateInterval!");
         }
         $executionNextPollDate = new \DateTime("now");
         $executionNextPollDate->add($variables['batchWaitInterval']);
         $executionNextPollDate = $executionNextPollDate->format($platform->getDateTimeFormatString());
     }
     $serializer = $this->options->getSerializer();
     $now = new \DateTime("now");
     $data = array('workflow_id' => (int) $this->workflow->id, 'execution_parent' => $parentId, 'execution_started' => $now->format($platform->getDateTimeFormatString()), 'execution_variables' => $serializer->serialize($variables), 'execution_waiting_for' => $serializer->serialize($this->waitingFor), 'execution_threads' => $serializer->serialize($this->threads), 'execution_next_thread_id' => (int) $this->nextThreadId, 'execution_next_poll_date' => $executionNextPollDate);
     if ($platform->prefersSequences()) {
         $data['execution_id'] = (int) $this->conn->fetchColumn($platform->getSequenceNextValSQL($this->options->executionSequence()));
         $this->id = $data['execution_id'];
     }
     $this->conn->insert($this->options->executionTable(), $data);
     // execution_id
     if (!$platform->prefersSequences()) {
         $this->id = (int) $this->conn->lastInsertId();
     }
 }
开发者ID:beberlei,项目名称:Doctrine-Workflow,代码行数:27,代码来源:DoctrineExecution.php

示例2: shouldBeJson

 /**
  * @test
  */
 public function shouldBeJson()
 {
     if (false === strpos($this->conn->fetchColumn('SELECT VERSION()'), '5.7')) {
         $this->markTestIncomplete('Only for mysql 5.7');
     }
     $create_query = "create table t1 (i INT, j JSON)";
     $insert_query = "INSERT INTO t1 VALUES \r\n            (0, NULL) , \r\n            (1, '{\"a\": 2}'),\r\n            (2, '[1,2]'),\r\n            (3, '{\"a\":\"b\", \"c\":\"d\",\"ab\":\"abc\", \"bc\": [\"x\", \"y\"]}'),\r\n            (4, '[\"here\", [\"I\", \"am\"], \"!!!\"]'),\r\n            (5, '\"scalar string\"'),\r\n            (6, 'true'),\r\n            (7, 'false'),\r\n            (8, 'null'),\r\n            (9, '-1'),\r\n            (10, CAST(CAST(1 AS UNSIGNED) AS JSON)),\r\n            (11, '32767'),\r\n            (12, '32768'),\r\n            (13, '-32768'),\r\n            (14, '-32769'),\r\n            (15, '2147483647'),\r\n            (16, '2147483648'),\r\n            (17, '-2147483648'),\r\n            (18, '-2147483649'),\r\n            (19, '18446744073709551615'),\r\n            (20, '18446744073709551616'),\r\n            (21, '3.14'),\r\n            (22, '{}'),\r\n            (23, '[]'),\r\n            -- (24, CAST(CAST('2015-01-15 23:24:25' AS DATETIME) AS JSON)),\r\n            -- (25, CAST(CAST('23:24:25' AS TIME) AS JSON)),\r\n            -- (125, CAST(CAST('23:24:25.12' AS TIME(3)) AS JSON)),\r\n            -- (225, CAST(CAST('23:24:25.0237' AS TIME(3)) AS JSON)),\r\n            -- (26, CAST(CAST('2015-01-15' AS DATE) AS JSON)),\r\n            -- (27, CAST(TIMESTAMP'2015-01-15 23:24:25' AS JSON)),\r\n            -- (127, CAST(TIMESTAMP'2015-01-15 23:24:25.12' AS JSON)),\r\n            -- (227, CAST(TIMESTAMP'2015-01-15 23:24:25.0237' AS JSON)),\r\n            -- (327, CAST(UNIX_TIMESTAMP('2015-01-15 23:24:25') AS JSON)),\r\n            -- (28, CAST(ST_GeomFromText('POINT(1 1)') AS JSON)),\r\n            (29, CAST('[]' AS CHAR CHARACTER SET 'ascii')),\r\n            -- (30, CAST(x'cafe' AS JSON)),\r\n            -- (31, CAST(x'cafebabe' AS JSON)),\r\n            (100, CONCAT('{\"', REPEAT('a', 64 * 1024 - 1), '\":123}'))\r\n        ";
     $event = $this->createAndInsertValue($create_query, $insert_query);
     $results = $event->getValues();
     self::assertEquals($results[0]['j'], null);
     self::assertEquals($results[1]['j'], '{"a":2}');
     self::assertEquals($results[2]['j'], '[1,2]');
     self::assertEquals($results[3]['j'], '{"a":"b","c":"d","ab":"abc","bc":["x","y"]}');
     self::assertEquals($results[4]['j'], '["here",["I","am"],"!!!"]');
     self::assertEquals($results[5]['j'], '"scalar string"');
     self::assertEquals($results[6]['j'], 'true');
     self::assertEquals($results[7]['j'], 'false');
     self::assertEquals($results[8]['j'], '"null"');
     self::assertEquals($results[9]['j'], '"-1"');
     self::assertEquals($results[10]['j'], '"1"');
     self::assertEquals($results[11]['j'], '"32767"');
     self::assertEquals($results[12]['j'], '"32768"');
     self::assertEquals($results[13]['j'], '"-32768"');
     self::assertEquals($results[14]['j'], '"-32769"');
     self::assertEquals($results[15]['j'], '"2147483647"');
     self::assertEquals($results[16]['j'], '"2147483648"');
     self::assertEquals($results[17]['j'], '"-2147483648"');
     self::assertEquals($results[18]['j'], '"-2147483649"');
     self::assertEquals($results[19]['j'], '"18446744073709551615"');
     self::assertEquals($results[20]['j'], '"1.844674407371E+19"');
     self::assertEquals($results[21]['j'], '"3.14"');
     self::assertEquals($results[22]['j'], '{}');
     self::assertEquals($results[23]['j'], '[]');
     self::assertEquals($results[24]['j'], '[]');
 }
开发者ID:krowinski,项目名称:php-mysql-replication,代码行数:38,代码来源:TypesTest.php

示例3: findMask

 /**
  * {@inheritdoc}
  */
 public function findMask(RequesterInterface $requester, ResourceInterface $resource)
 {
     if (false === ($mask = $this->connection->fetchColumn('SELECT mask FROM ' . $this->getAclSchema()->getPermissionsTableName() . ' WHERE requester = :requester AND resource = :resource', ['requester' => $requester->getAclRequesterIdentifier(), 'resource' => $resource->getAclResourceIdentifier()], 0, ['requester' => \PDO::PARAM_STR, 'resource' => \PDO::PARAM_STR]))) {
         throw new MaskNotFoundException();
     }
     return (int) $mask;
 }
开发者ID:alexdpy,项目名称:acl,代码行数:10,代码来源:DoctrineDbalProvider.php

示例4: find

 /**
  * {@inheritdoc}
  */
 public function find($key, $ttl)
 {
     $data = $this->db->fetchColumn('SELECT user FROM ' . $this->table . ' WHERE id = ? AND time > ?', [$key, time() - $ttl], 0);
     if (!$data) {
         return false;
     }
     return $data;
 }
开发者ID:minchal,项目名称:vero,代码行数:11,代码来源:DatabaseProvider.php

示例5: load

 /**
  * {@inheritdoc}
  */
 public function load($id, $ttl)
 {
     $data = $this->db->fetchColumn('SELECT data FROM ' . $this->table . ' WHERE sid = ? AND time > ?', [$id, time() - $ttl], 0);
     if (!$data) {
         return false;
     }
     return unserialize($data);
 }
开发者ID:minchal,项目名称:vero,代码行数:11,代码来源:Database.php

示例6: countMyIsamTables

	/**
	 * @param $dbName
	 * @return mixed
	 */
	private function countMyIsamTables() {
		$dbName = \OC::$server->getConfig()->getSystemValue("dbname");

		$result = $this->connection->fetchColumn(
			"SELECT count(*) FROM information_schema.tables WHERE table_schema = ? and table_name = ? AND engine = 'MyISAM'",
			array($dbName, $this->tableName)
		);
		return $result;
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:13,代码来源:repairinnodb.php

示例7: findMilestoneProgressForAreasInGroup

 public function findMilestoneProgressForAreasInGroup(Group $group)
 {
     $totalMilestones = $this->conn->fetchColumn('SELECT COUNT(`id`) FROM `' . MilestoneTables::MILESTONE_TBL . '` WHERE `projectId` = :projectId AND `entityType` = \'Area\'', [':projectId' => $group->getProject()->getId()]);
     $results = $this->conn->fetchAll('SELECT a.`id`, a.`name`, a.`entityId`, p.`completedNum` ' . 'FROM `' . CoreTables::AREA_TBL . '` a ' . 'INNER JOIN `' . MilestoneTables::MILESTONE_PROGRESS_TBL . '` p ON p.`entityId` = a.`entityId` ' . 'WHERE a.`groupId` = :groupId ' . 'ORDER BY p.`completedNum` DESC, a.`name`', [':groupId' => $group->getId()]);
     foreach ($results as &$result) {
         $this->processResult($totalMilestones, $result);
     }
     return $results;
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:9,代码来源:MilestoneSummaryRepository.php

示例8: getInstalledVersion

 protected function getInstalledVersion(Schema $schema)
 {
     if ($schema->hasTable('fusio_meta')) {
         $version = $this->connection->fetchColumn('SELECT version FROM fusio_meta ORDER BY installDate DESC, id DESC LIMIT 1');
         if (!empty($version)) {
             return $version;
         }
     }
     return null;
 }
开发者ID:apioo,项目名称:fusio-impl,代码行数:10,代码来源:InstallCommand.php

示例9: getTsExcellenceData

 /**
  * gets the values of the excellence plugin
  *
  * @return array
  * @param $pluginId
  */
 private function getTsExcellenceData($pluginId)
 {
     $sql = "SELECT id\n                FROM  `s_core_config_forms`\n                WHERE  `plugin_id` = ?";
     $tsExcFormId = $this->db->fetchColumn($sql, array($pluginId));
     $sql = "SELECT id, name, value\n                FROM `s_core_config_elements`\n                WHERE `form_id` = ?";
     $tsExcElementsTemp = $this->db->fetchAll($sql, array($tsExcFormId));
     $tsExcElements = array();
     foreach ($tsExcElementsTemp as $element) {
         $tsExcElements[] = array('id' => $element['id'], 'name' => $element['name'], 'defaultValue' => $element['value']);
     }
     $tsExcValuesTemp = array();
     foreach ($tsExcElements as $element) {
         $sql = "SELECT shop_id,element_id, value\n                    FROM `s_core_config_values`\n                    WHERE `element_id` = ?";
         $tsExcValuesTemp[] = $this->db->fetchAll($sql, array($element['id']));
     }
     //converts the data into a nice array
     $tsExcValues = array();
     foreach ($tsExcElements as $element) {
         foreach ($tsExcValuesTemp as $values) {
             if (empty($values)) {
                 continue;
             }
             foreach ($values as $value) {
                 if ($element['id'] == $value['element_id']) {
                     $tsExcValues[$element['name']][$value['shop_id']] = unserialize($value['value']);
                 }
             }
         }
     }
     return $tsExcValues;
 }
开发者ID:Goucher,项目名称:shopware,代码行数:37,代码来源:MigrationService.php

示例10: getDbConnection

/**
 * @param Connection $connection
 * @return Connection
 */
function getDbConnection($connection)
{
    $currentVersion = getDbPatcherVersion();
    try {
        $version = $connection->fetchColumn('SELECT db_patcher_version()');
    } catch (DBALException $e) {
        createDbPatcherVersionSqlFunction($connection);
        $connection->executeQuery(<<<SQL
CREATE TABLE db_patcher
(
  id serial NOT NULL,
  "name" text NOT NULL,
  status smallint NOT NULL DEFAULT 0,
  md5 text NOT NULL,
  CONSTRAINT pk_db_patch PRIMARY KEY (id ),
  CONSTRAINT ak_key_2_db_patch UNIQUE ("name")
)
SQL
);
        $version = $currentVersion;
    }
    if (version_compare($currentVersion, $version) > 0) {
        updateDbPatcherDatabase($connection, $version);
        createDbPatcherVersionSqlFunction($connection);
    }
    return $connection;
}
开发者ID:jamayka,项目名称:db-patcher,代码行数:31,代码来源:functions.php

示例11: getNumberOfExecutedMigrations

 /**
  * Returns the total number of executed migration versions
  *
  * @return integer
  */
 public function getNumberOfExecutedMigrations()
 {
     $this->connect();
     $this->createMigrationTable();
     $result = $this->connection->fetchColumn("SELECT COUNT(" . $this->migrationsColumnName . ") FROM " . $this->migrationsTableName);
     return $result !== false ? $result : 0;
 }
开发者ID:doctrine,项目名称:migrations,代码行数:12,代码来源:Configuration.php

示例12: update

 /**
  * Update entity in the database (partial data is supported).
  *
  * @param \Lokhman\Silex\ARM\AbstractEntity $entity
  *
  * @throws \Exception
  * @return integer
  *         Number of affected rows
  */
 public function update(AbstractEntity $entity)
 {
     $this->assert($entity);
     // check if primary key is defined and is not NULL
     $primary = $this->metadata->getPrimary();
     if (!isset($entity[$primary])) {
         self::raise('Primary key is required to update the entity.');
     }
     try {
         $this->db->beginTransaction();
         // pre-update event
         $this->preUpdate($entity);
         // validate entity
         $this->validateUpdate($entity);
         // if position column exists
         if ($this->metadata->hasPosition()) {
             $this->positionUpdate($entity);
         }
         // get raw data from entity
         $data = AbstractEntity::raw($entity);
         $id = $data[$primary];
         unset($data[$primary]);
         if ($this->translate) {
             $sql = 'SELECT COUNT(*) FROM ' . $this->app['arm.trans'] . ' WHERE _table = :_table AND _key = :_key AND ' . '_column = :_column AND _locale = :_locale';
             // for each translatable column in schema
             foreach ($this->metadata->getTrans() as $column) {
                 // if no column presented in the data
                 if (!array_key_exists($column, $data)) {
                     continue;
                 }
                 $trans = ['_table' => $this->table, '_key' => $id, '_column' => $column, '_locale' => $this->locale];
                 if ($data[$column] === null) {
                     // if column exists but is NULL: delete translation
                     $this->db->delete($this->app['arm.trans'], $trans);
                 } elseif ($this->db->fetchColumn($sql, $trans) > 0) {
                     // if translation exists: update translation
                     $this->db->update($this->app['arm.trans'], ['_content' => $data[$column]], $trans);
                 } else {
                     // if translation doesn't exist: insert translation
                     $this->db->insert($this->app['arm.trans'], $trans + ['_content' => $data[$column]]);
                 }
                 // remove value from actual data
                 unset($data[$column]);
             }
         }
         if ($data) {
             // update entity data if there is anything to update
             $result = $this->db->update($this->table, $data, [$primary => $id]);
         }
         $this->db->commit();
         // post-update event
         $this->postUpdate($entity);
     } catch (\Exception $ex) {
         $this->unlink($entity);
         $this->rollback();
         throw $ex;
     }
     return $result;
 }
开发者ID:lokhman,项目名称:silex-arm,代码行数:68,代码来源:Repository.php

示例13: getRowCount

 /**
  * Returns the number of rows in the given table. You can specify an
  * optional where clause to return a subset of the table.
  *
  * @param string $tableName
  * @param string $whereClause
  * @param int
  */
 public function getRowCount($tableName, $whereClause = NULL)
 {
     $sql = "SELECT count(*) FROM " . $tableName;
     if ($whereClause !== null) {
         $sql .= " WHERE " . $whereClause;
     }
     return $this->_conn->fetchColumn($sql);
 }
开发者ID:matiasraies,项目名称:Symfony2Inta,代码行数:16,代码来源:TestConnection.php

示例14: save

 public function save(Connection $conn)
 {
     $exists = $conn->fetchColumn('SELECT `id` FROM `' . ForumTables::FORUM_ROOT_TBL . '` WHERE `id` = :id', [':id' => $this->id]);
     if (!empty($exists)) {
         $conn->insert(ForumTables::FORUM_ROOT_TBL, ['id' => $id, 'name' => $name]);
     } else {
         $conn->update(ForumTables::FORUM_ROOT_TBL, ['id' => $id, 'name' => $name]);
     }
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:9,代码来源:ForumRoot.php

示例15: exists

 /**
  * Checks whether the given managed entity exists in the database.
  *
  * @param object $entity
  * @return boolean TRUE if the entity exists in the database, FALSE otherwise.
  */
 public function exists($entity, array $extraConditions = array())
 {
     $criteria = $this->_class->getIdentifierValues($entity);
     if ($extraConditions) {
         $criteria = array_merge($criteria, $extraConditions);
     }
     $sql = 'SELECT 1 ' . $this->getLockTablesSql() . ' WHERE ' . $this->_getSelectConditionSQL($criteria);
     return (bool) $this->_conn->fetchColumn($sql, array_values($criteria));
 }
开发者ID:jfkz,项目名称:aquarel-cms,代码行数:15,代码来源:BasicEntityPersister.php


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