Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add totals #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rumours86 wants to merge 5 commits into FriendsOfDoctrine:master
base: master
Choose a base branch
Loading
from rumours86:master
Open

add totals #24

rumours86 wants to merge 5 commits into FriendsOfDoctrine:master from rumours86:master

Conversation

Copy link

@rumours86 rumours86 commented Mar 18, 2019

No description provided.

stanislav-reshetnev and yapro reacted with thumbs up emoji rumours86, demenkov, max-gryshin, and yapro reacted with hooray emoji demenkov, SweetyVioletta, and yapro reacted with heart emoji
Copy link

@stanislav-reshetnev stanislav-reshetnev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "totals" may be not needed at results. It must be manipulated by input parameter. An extra data like additional "totals" entry can destroy existing applications.

Copy link
Author

The "totals" may be not needed at results. It must be manipulated by input parameter. An extra data like additional "totals" entry can destroy existing applications.

I thought about it, but I have no idea how not to break existing applications and add total output

And it should not break anything, unless someone uses a query with "WITH TOTALS", but why use it if it cannot be displayed?

Copy link

I thought about it, but I have no idea how not to break existing applications and add total output

I added getTotals() method for the replaced vendor's class for it in my application:

 public function getTotals(): array
 {
 return $this->_client_statement->totals();
 }

Copy link
Author

rumours86 commented Mar 18, 2019
edited
Loading

I thought about it, but I have no idea how not to break existing applications and add total output

I added getTotals() method for the replaced vendor's class for it in my application:

 public function getTotals(): array
 {
 return $this->_client_statement->totals();
 }

how i can use this in controller or template or pager ?

Copy link

how i can use this in controller or template or pager ?

Here is using in my Symfony service:

 /** @var ClickhouseConnection $conn */
 $conn = $this->_doctrine_manager->getConnection('clickhouse');
 $q = $conn->createQueryBuilder();
// ...
 /** @var \App\VendorReplace\ClickhouseStatement $clickhouse_stmt */
 $clickhouse_stmt = $q->execute();
 $totals = $clickhouse_stmt->getTotals();

I do not use database access in controllers or templates.

Copy link
Author

okay

Copy link

yapro commented Mar 22, 2020
edited
Loading

My solution:

/**@var \FOD\DBALClickHouse\Connection $conn */
$olapConnection = $this->_doctrine_manager->getConnection('clickhouse');
$clickHouseConnection = $olapConnection->getWrappedConnection();
$class = new \ReflectionClass($clickHouseConnection);
$property = $class->getProperty('smi2CHClient');
$property->setAccessible(true);
/** @var \ClickHouseDB\Client $client */
$client = $property->getValue($clickHouseConnection);
$params = ['field3' => 'value'];
$statement = $client->select('SELECT field1, COUNT(*) AS field2 FROM table1 WHERE field3 = :field3 GROUP BY field1 LIMIT 5, 10', $params);
$statement->rows(); // get rows by LIMIT 
$statement->countAll(); // Count all rows (like LIMIT not using) - for implementation my pagination

Details in the documentation https://github.com/smi2/phpClickHouse#start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@stanislav-reshetnev stanislav-reshetnev stanislav-reshetnev left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /