Skip to content

Instantly share code, notes, and snippets.

@AstDerek
Created February 17, 2013 04:00
Show Gist options
  • Save AstDerek/4970078 to your computer and use it in GitHub Desktop.
Save AstDerek/4970078 to your computer and use it in GitHub Desktop.
Comparison between original code, and ORM code
<?php
// Without ORM
$forum_id = 0;
$query = "select id from imas_forums where courseid = ".$_GET['courseid'];
$result = mysql_query($query) or die("Query failed: ".mysql_error());
$foro = mysql_fetch_row($result);
if(count($foro)>0)
$forum_id = $foro[0];
// With ORM
$forum = ORM::for_table('imas_forums')->where('courseid',$_GET['courseid'])->find_one();
$forum_id = $forum ? $forum->id : 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment