Skip to content

Instantly share code, notes, and snippets.

@squallcx
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squallcx/05a169d4a53e5ba810f2 to your computer and use it in GitHub Desktop.
Save squallcx/05a169d4a53e5ba810f2 to your computer and use it in GitHub Desktop.
database
------------------
table:project
id;name;classid
451;小明;2
533;小黃;2
388;小宝;3
table:class
id;name
1;高级
2;中级
3;低级
-----------------
<?php
$projects=ORM::for_table('project')->find_many();
$classs=ORM::for_table('class')->find_many();
foreach($projects as $project){
echo $project->url;
echo $project->name;
foreach($classs as $class){
if($project->classid==$classs->id){
echo $classs->name;
break;
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment