Chainquery integration #49
3 changed files with 5 additions and 5 deletions
|
@ -218,7 +218,7 @@ return [
|
|||
* See vendor\cakephp\cakephp\src\Database\Driver for complete list
|
||||
*/
|
||||
'Datasources' => [
|
||||
'default' => [
|
||||
'default' => [ // Chainquery database connection
|
||||
'className' => 'Cake\Database\Connection',
|
||||
'driver' => 'Cake\Database\Driver\Mysql',
|
||||
'persistent' => false,
|
||||
|
@ -260,7 +260,7 @@ return [
|
|||
'url' => env('DATABASE_URL', 'chainquery.lbry.io:3600'),
|
||||
],
|
||||
|
||||
'localdb' => [
|
||||
'localdb' => [ // Local db for price history
|
||||
'className' => 'Cake\Database\Connection',
|
||||
'driver' => 'Cake\Database\Driver\Mysql',
|
||||
'persistent' => false,
|
||||
|
|
|
@ -579,9 +579,9 @@ class MainController extends AppController {
|
|||
|
||||
// get avg prices
|
||||
$conn_local = ConnectionManager::get('localdb');
|
||||
$stmt = $conn_local->execute("SELECT AVG(USD) AS AvgUSD, DATE_FORMAT(Created, '$sqlDateFormat') AS TimePeriod " .
|
||||
$stmt_price = $conn_local->execute("SELECT AVG(USD) AS AvgUSD, DATE_FORMAT(Created, '$sqlDateFormat') AS TimePeriod " .
|
||||
"FROM PriceHistory WHERE DATE_FORMAT(Created, '$sqlDateFormat') >= ? GROUP BY TimePeriod ORDER BY TimePeriod ASC", [$start->format($dateFormat)]);
|
||||
$avgPrices = $stmt->fetchAll(\PDO::FETCH_OBJ);
|
||||
$avgPrices = $stmt_price->fetchAll(\PDO::FETCH_OBJ);
|
||||
foreach ($avgPrices as $price) {
|
||||
if (!isset($resultSet[$price->TimePeriod])) {
|
||||
$resultSet[$price->TimePeriod] = [];
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace App\Model\Entity;
|
|||
use Cake\ORM\Entity;
|
||||
|
||||
class PriceHistory extends Entity {
|
||||
|
||||
public $useDbConfig = 'localdb';
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in a new issue