SELECT groups.groupID AS groupID, groups.groupName AS groupName, invTypes.typeName AS skillName, invTypes.description AS skillDescription, invTypes.typeID FROM ( SELECT * FROM invGroups WHERE categoryID = 16 AND published = 1 ) AS groups INNER JOIN invTypes ON ( invTypes.groupID = groups.groupID AND invTypes.published = 1 ) ORDER BY groupName
You don't, but the View class does. It will sanitize the variables passed for output. Nothing will block you from using a mix of ORM and DB calls, I use that myself in my nestedsets model extension. Some queries (like for example update's) can't be run through ORM because it's focused on the loaded objects.Harro Verton wrote on Wednesday 18th of May 2011:The DB::query()->execute() is the way to go. You get the error message because somewhere in your code you try to manipulate the query result. It is returned as a result object, which you can't modify (i.e. you can not assign anything to it).
<?php foreach ($skills as $skill): ?> <tr> <td width="5%"><?php echo $skill->groupId ?></td> <td width="10%"><?php echo $skill->groupId ?></td> <td><?php echo $skill->groupId ?></td> <td><?php echo $skill->groupId ?></td> </tr> <?php endforeach; ?>
Orm is short for Object Relational Mapper which does 2 things: it maps your database table rows to objects and it allows you to establish relations between those objects.
"it maps your database table rows to objects", thus each individual table row from each individual table is a separate object. That is completely different from the DataBase_Result object that the Query Builder returns. That just wraps the resultset and allows you to have some utility methods on the result. I'm sorry but from the way you interpret all of this it's clear you don't fully understand what the Query Builder does and what an Orm does. I'd suggest reading up on Orms on Wikipedia.So the ORM as the O stands for returns an object. WanWizard tells me the error I get is caused of the result I get, was an object. So what's the difference?
$query = DB::select('SELECT groups.groupID AS groupID, groups.groupName AS groupName, invTypes.typeName AS skillName, invTypes.description AS skillDescription, invTypes.typeID FROM ( SELECT * FROM invGroups WHERE categoryID = 16 AND published = 1 ) AS groups INNER JOIN invTypes ON ( invTypes.groupID = groups.groupID AND invTypes.published = 1 ) ORDER BY groupName')->execute();
1064! Fuel\Core\Database_Exception [ 1064 ]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`typeName AS skillName, invTypes`.`description AS skillDescription, invTy' at line 1 [ SELECT `SELECT groups`.`groupID AS groupID, groups`.`groupName AS groupName, invTypes`.`typeName AS skillName, invTypes`.`description AS skillDescription, invTypes`.`typeID FROM ( SELECT * FROM invGroups WHERE categoryID = 16 AND published = 1 ) AS groups INNER JOIN invTypes ON ( invTypes`.`groupID = groups`.`groupID AND invTypes`.`published = 1 ) ORDER BY groupName` ]
Fuel\Core\Fuel_Exception [ Error ]: Database results are read-only
It looks like you're new here. If you want to get involved, click one of these buttons!