1

I need some help, I have to implement this sql query in zend2:

SET @i:=-1; SELECT COUNT(*) AS cnt, AVG(ch01) AS ch01avg  FROM (
     SELECT @i:=@i+1 AS rownum,FLOOR(@i/60) AS GGG,ch01 
     FROM binTable 
     WHERE SUBDATE(NOW(),INTERVAL 11 DAY)<= start_date_time
)AS t GROUP BY GGG;

Feel free to use any other sql query as long it fulfulls the purpose, which is: getting the average of ch01 of every 60 entries.

Im not a native english speaker, Im eastern european :D.

1 Answer 1

1

Hi there i maneged to find a solution which works for me:

Having an instance of

Zend\Db\TableGateway\TableGateway

object which represents the table from which i want to make the query I did this:

$this->binTable is the Zend\Db\TableGateway\TableGateway object:

$result = $this->binTable->getAdapter()->query(" HERE GOES THE SQL QUERY ")->execute();

     use Zend\Db\ResultSet\ResultSet;

$resultSet = new ResultSet;
$resultSet->initialize($result);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.