/**
  * Add main response fields.
  *
  * @param Mysql $query
  */
 protected function setResponseData(Mysql $query)
 {
     $query_rows = clone $query;
     $this->setResponse('total_items', $query_rows->nolimit()->nogroupby()->noorderby()->count()->get()->counter());
     //$this->setResponse('total_items', $query_rows->nolimit()->noorderby()->get()->count());
     $this->setResponse('cur_page', $this->cur_page);
     $this->setResponse('selected_item', $this->selected_item);
     $this->setResponse('data', $query->get()->all());
 }
Esempio n. 2
0
 /**
  * @covers mychaelstyle\storage\providers\Mysql::get
  * @depends testPut
  */
 public function testGet()
 {
     $this->object->connect($this->uri, $this->options);
     // get contents
     $contents = $this->object->get('/tmp.txt');
     $this->assertEquals(file_get_contents($this->org_example), $contents);
     // to file
     $tmp = tempnam(sys_get_temp_dir(), 'tmp_mychaelstyle_storage_mysql_test_');
     $result = $this->object->get('/tmp.txt', $tmp);
     $this->assertTrue($result);
     $this->assertEquals(file_get_contents($this->org_example), file_get_contents($tmp));
     // disconnect
     $this->object->disconnect();
 }