function __construct(array $args) { parent::__construct($args); $this->values = DataSource::value($args, 'values', 1); $this->headerRow = DataSource::value($args, 'headerRow', 2); // Check integrity if (!is_array($this->values)) { $this->values = [$this->values]; } }
public function init() { parent::init(); // Create unique name if not set if (!$this->name) { $class = get_class($this); $class = strtolower($class); $this->name = uniqid($class); } // Create dummy data source if (!$this->source) { $this->source = ['array', [['value_1_1', 'value_1_2'], ['value_2_1', 'value_2_2']]]; } $this->data = DataSource::create($this->source); // Filter data $filter = $this->filter(); if ($filter) { $this->data->filter($filter); } }
function __construct(array $args) { parent::__construct($args); // Get table name $this->table = DataSource::value($args, 'table', 1); $this->table = strval($this->table); // Get certain columns $this->columns = DataSource::value($args, 'columns', 2); if ($this->columns && !is_array($this->columns)) { $this->columns = [$this->columns]; } // Get distinct option $this->distinct = (bool) DataSource::value($args, 'distinct', 3); // Get OrderBy option $this->order = DataSource::value($args, 'order', 3); if ($this->order && !is_array($this->order)) { $this->order = [$this->order => 'ASC']; } $this->build(); }