pool/web/yaamp/models/db_market_historyModel.php
Tanguy Pruvot bf7fc3534f sql: keep btc and user defined markets history
will allow to do internal graphes and compute better exchange orders

Also track in the new table a (BTC/EUR) alternative, from kraken public api
this second currency should be user definable later.
2016-04-24 10:23:21 +02:00

46 lines
898 B
PHP

<?php
/**
* This table tracks currency price and your balance on a market
*/
class db_market_history extends CActiveRecord
{
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function tableName()
{
return 'market_history';
}
public function rules()
{
return array(
array('idcoin', 'required'),
array('idcoin, idmarket', 'numerical', 'integerOnly'=>true),
);
}
public function relations()
{
return array(
'coin' => array(self::BELONGS_TO, 'db_coins', 'idcoin', 'alias'=>'mh_coin'),
'market' => array(self::BELONGS_TO, 'db_markets', 'idmarket', 'alias'=>'mh_market'),
);
}
public function attributeLabels()
{
return array(
);
}
public function save($runValidation=true,$attributes=null)
{
if (empty($this->idmarket)) $this->idmarket = null;
return parent::save($runValidation, $attributes);
}
}