This works and shows the result set:
$mainFeatures = new Mainfeature;
$mainFeatures->getConnection()->setFetchMode(PDO::FETCH_KEY_PAIR);
$main = $mainFeatures::get(array('id','data'))->toArray();
dd($main);
But if i try to return with the result set:
return View::make('orders.create')
->with('features', Feature::with('Subfeature')->get()->toArray())
->with('mainFeatures', $main);
It gives an error:
SQLSTATE[HY000]: General error: PDO::FETCH_KEY_PAIR fetch mode requires the result set to contain extactly 2 columns. (SQL: select * from `features`) (Bindings: array ( ))
Not sure from where select * from features
comes in...
I missed that i was changing the fetch mode for the connection
and not just the class Mainfeature
. So i had to reset it.
$mainFeatures = new Mainfeature;
$mainFeatures->getConnection()->setFetchMode(PDO::FETCH_KEY_PAIR);
$main = $mainFeatures::get(array('id','data'))->toArray();
//dd($h);
//dd($main);
$features = new Feature;
$features->getConnection()->setFetchMode(PDO::FETCH_CLASS);
return View::make('orders.create')
->with('features', $features::with('Subfeature')->get()->toArray())
->with('mainFeatures', $main);
Credit goes to Clive for pointing me in the right direction.