Hi all,
I am working on my website called belminuten.net.
I have created a custom page that does a query for data. Please find the code below.
$sqlQuery = new SQLQuery();
$sqlQuery->setFrom('simonly_abo');
$sqlQuery->selectField('id', 'id');
$sqlQuery->selectField('abo_type', 'abo_type');
$sqlQuery->selectField('abo_minutes', 'abo_minutes');
$sqlQuery->selectField('abo_sms', 'abo_sms');
$sqlQuery->selectField('abo_data', 'abo_data');
$sqlQuery->selectField('abo_time', 'abo_time');
$sqlQuery->selectField('abo_price', 'abo_price');
$sqlQuery->addWhere('provider = \''.$this->brand.'\'');
$sqlQuery->setOrderBy('abo_price');
$sqlQuery->selectField('img','img');
$result = $sqlQuery->execute();
It works great, but when i check the full query with
echo $sqlQuery->sql();
I get:
SELECT *, id, abo_type, abo_minutes, abo_sms, abo_data, abo_time, abo_price, img, CONCAT(abo_time,'_',abo_minutes,'_',abo_data) AS "slug" FROM simonly_abo WHERE (provider = 'aess44') GROUP BY slug ORDER BY abo_price ASC
I only need the fields I selected, but silverstripe puts * at the beginning of the query. How can I prevent this from happening?
Regards,
Jombo.
UPDATE: i figured it out. I used setSelect() instead of selectField(). that solved the problem.