本文整理汇总了PHP中Magento\Framework\DB\Adapter\AdapterInterface::fetchRow方法的典型用法代码示例。如果您正苦于以下问题:PHP AdapterInterface::fetchRow方法的具体用法?PHP AdapterInterface::fetchRow怎么用?PHP AdapterInterface::fetchRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DB\Adapter\AdapterInterface
的用法示例。
在下文中一共展示了AdapterInterface::fetchRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAggregate
/**
* @magentoDataFixture Magento/Review/_files/customer_review_with_rating.php
*/
public function testAggregate()
{
$rating = $this->reviewCollection->getFirstItem();
$this->reviewResource->aggregate($rating);
$select = $this->adapter->select()->from($this->resource->getTableName('review_entity_summary'));
$result = $this->adapter->fetchRow($select);
$this->assertEquals(1, $result['reviews_count']);
$this->assertEquals(40, $result['rating_summary']);
}
示例2: getAggregations
/**
* {@inheritdoc}
*/
public function getAggregations(\Magento\Framework\Search\Dynamic\EntityStorage $entityStorage)
{
$aggregation = ['count' => 'count(DISTINCT main_table.entity_id)', 'max' => 'MAX(min_price)', 'min' => 'MIN(min_price)', 'std' => 'STDDEV_SAMP(min_price)'];
$select = $this->getSelect();
$tableName = $this->resource->getTableName('catalog_product_index_price');
/** @var Table $table */
$table = $entityStorage->getSource();
$select->from(['main_table' => $tableName], [])->joinInner(['entities' => $table->getName()], 'main_table.entity_id = entities.entity_id', [])->columns($aggregation);
$select = $this->setCustomerGroupId($select);
$result = $this->connection->fetchRow($select);
return $result;
}
示例3: getByOdooId
/** @inheritdoc */
public function getByOdooId($odooId)
{
/** @var $result AggWarehouse */
$result = null;
$query = $this->_factorySelect->getQueryToSelect();
$query->where(static::AS_ODOO . '.' . EntityWarehouse::ATTR_ODOO_REF . '=:id');
$data = $this->_conn->fetchRow($query, ['id' => $odooId]);
if ($data) {
$result = $this->_manObj->create(AggWarehouse::class);
$result->setData($data);
}
return $result;
}
示例4: testInsertForce
/**
* @dataProvider insertDataProvider
*/
public function testInsertForce($data)
{
$this->assertEquals(1, $this->_connection->insertForce($this->_tableName, $data));
$select = $this->_connection->select()->from($this->_tableName);
$result = $this->_connection->fetchRow($select);
$this->assertEquals($data, $result);
}
示例5: loadNode
/**
* @param mixed $nodeId
* @return Node
*/
public function loadNode($nodeId)
{
$select = clone $this->_select;
$condition = $this->_conn->quoteInto("{$this->_table}.{$this->_idField}=?", $nodeId);
$select->where($condition);
$node = new Node($this->_conn->fetchRow($select), $this->_idField, $this);
$this->addNode($node);
return $node;
}
示例6: getNode
/**
* @param string|int $nodeId
* @return Node
*/
public function getNode($nodeId)
{
$dbSelect = new Select($this->_db);
$dbSelect->from($this->_table)->where($this->_table . '.' . $this->_id . ' >= :id');
$this->_addExtTablesToSelect($dbSelect);
$data = [];
$data['id'] = $nodeId;
$data = $this->_db->fetchRow($dbSelect, $data);
return new Node($data, $this->getKeys());
}
示例7: testWriteEncoded
/**
* Assert that session data writes to DB in base64 encoding
*/
public function testWriteEncoded()
{
$data = serialize($this->_sessionData[self::SESSION_NEW]);
$this->_model->write(self::SESSION_ID, $data);
$select = $this->_connection->select()->from($this->_sessionTable)->where(self::COLUMN_SESSION_ID . ' = :' . self::COLUMN_SESSION_ID);
$bind = [self::COLUMN_SESSION_ID => self::SESSION_ID];
$session = $this->_connection->fetchRow($select, $bind);
$this->assertEquals(self::SESSION_ID, $session[self::COLUMN_SESSION_ID]);
$this->assertTrue(ctype_digit((string) $session[self::COLUMN_SESSION_EXPIRES]), 'Value of session expire field must have integer type');
$this->assertEquals($data, base64_decode($session[self::COLUMN_SESSION_DATA]));
}
示例8: loadNode
/**
* Load node
*
* @param int|string $nodeId
* @return Node
*/
public function loadNode($nodeId)
{
$select = clone $this->_select;
if (is_numeric($nodeId)) {
$condField = $this->_conn->quoteIdentifier([$this->_table, $this->_idField]);
} else {
$condField = $this->_conn->quoteIdentifier([$this->_table, $this->_pathField]);
}
$select->where("{$condField} = ?", $nodeId);
$node = new Node($this->_conn->fetchRow($select), $this->_idField, $this);
$this->addNode($node);
return $node;
}
示例9: getVersion
/**
* Get maximum version_id from changelog
*
* @return int
* @throws \Exception
*/
public function getVersion()
{
$changelogTableName = $this->resource->getTableName($this->getName());
if (!$this->connection->isTableExists($changelogTableName)) {
throw new \Exception("Table {$changelogTableName} does not exist");
}
$row = $this->connection->fetchRow('SHOW TABLE STATUS LIKE ?', [$changelogTableName]);
if (isset($row['Auto_increment'])) {
return (int) $row['Auto_increment'] - 1;
} else {
throw new \Exception("Table status for `{$changelogTableName}` is incorrect. Can`t fetch version id.");
}
}
示例10: getById
/**
* @inheritdoc
*
* @SuppressWarnings(PHPMD.ShortVariable)
*/
public function getById($id)
{
/** @var $result AggWarehouse */
$result = null;
$query = $this->_factorySelect->getQueryToSelect();
$query->where(static::AS_STOCK . '.' . Cfg::E_CATINV_STOCK_A_STOCK_ID . '=:id');
$data = $this->_conn->fetchRow($query, ['id' => $id]);
if ($data) {
$result = $this->_manObj->create(AggLot::class);
$result->setData($data);
}
return $result;
}
示例11: loadByCustomerData
/**
* Load subscriber by customer
*
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
* @return array
*/
public function loadByCustomerData(\Magento\Customer\Api\Data\CustomerInterface $customer)
{
$select = $this->connection->select()->from($this->getMainTable())->where('customer_id=:customer_id');
$result = $this->connection->fetchRow($select, ['customer_id' => $customer->getId()]);
if ($result) {
return $result;
}
$select = $this->connection->select()->from($this->getMainTable())->where('subscriber_email=:subscriber_email');
$result = $this->connection->fetchRow($select, ['subscriber_email' => $customer->getEmail()]);
if ($result) {
return $result;
}
return [];
}
示例12: getTableStatus
/**
* Retrieve table status
*
* @param string $tableName
* @return \Magento\Framework\DataObject|bool
*/
public function getTableStatus($tableName)
{
$row = $this->connection->showTableStatus($tableName);
if ($row) {
$statusObject = new \Magento\Framework\DataObject();
foreach ($row as $field => $value) {
$statusObject->setData(strtolower($field), $value);
}
$cntRow = $this->connection->fetchRow($this->connection->select()->from($tableName, 'COUNT(1) as rows'));
$statusObject->setRows($cntRow['rows']);
return $statusObject;
}
return false;
}
示例13: getByOdooId
/** @inheritdoc */
public function getByOdooId($id)
{
$result = null;
if (is_null($id)) {
$this->_checkNullLot();
}
$query = $this->_factorySelect->getQueryToSelect();
$where = static::AS_ODOO . '.' . EntityLot::ATTR_ODOO_REF . '=:id';
$query->where($where);
$data = $this->_conn->fetchRow($query, ['id' => $id]);
if ($data) {
/** @var $result AggLot */
$result = $this->_manObj->create(AggLot::class);
$result->setData($data);
}
return $result;
}
示例14: doFindByFilter
/**
* {@inheritdoc}
*/
protected function doFindByFilter($filter)
{
return $this->connection->fetchRow($this->prepareSelect($filter));
}
示例15: doFindOneByData
/**
* {@inheritdoc}
*/
protected function doFindOneByData($data)
{
return $this->connection->fetchRow($this->prepareSelect($data));
}