Best Practices ? Adding child rows via ActiveRecord & Crud Style Forms

Hi, I’m starting to understand the AR/Crud model a little better and i was wondering if someone might help me out with a best practices question.

  1. Let’s say I have an admin section called “schools”, and a school_id is being passed around in the querystring… maybe the school can be edited, add photos, etc, and maybe I’d add a student to the school… what i’d like to know, is what is the best practice to pass this school_id through to a new student upon saving?

Is there a more appropriate way of doing this than what I’ve outlined below?

  1. I’m also curious as to how I can get the sql string of a statement without actually saving the data in the controller… sort of a hypothetical save that I can print in a view… or is there a better way to do this?

Thanks! Bryan

//In the conroller///////

public function actionStudentCreate($school_id=0){

//Where school_id is passed in from GET

    $model=new Student;




            $model->setAttribute("school_id", $school_id);