Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////// JS method ///////////////////////////////////
- setDetails:function(id){
- var view = M.ViewManager.getViewById(id);
- var courseName = M.ViewManager.getView(view,'courseNameLabel').value;
- var searchString = this.get('searchString');
- M.Request.init({
- url:"/mysql/database.php",
- isJSON: YES,
- data:{
- functionID:3,
- course: courseName,
- byDate: searchString
- },
- onSuccess:function(data){
- console.log(data);
- },
- }).send();
- //this.showDetails();
- },
- ///////////////////////////////////////////////////// php method ////////////////////////////////////////
- function getCoursesDetails($course,$date)
- {
- $query = "SELECT course.courseID, course.courseName, course_room.roomID,course_room.day_date, course_room.start_time, course_room.end_time, prof.firstName, prof.lastName, prof.profID FROM course, course_room, prof
- WHERE course_room.courseID = course.courseID AND course.courseName = $course AND course_room.day_date = $date AND prof.profID = course.profID";
- $result = mysql_query($query);
- $arr = array();
- while($record = mysql_fetch_assoc($result))
- {
- $arr[] = array ('courseID' => $record['courseID'],
- 'courseName' => $record['courseName'],
- 'roomID' => $record['roomID'],
- 'date' => $record['day_date'],
- 'starting' => $record ['start_time'],
- 'ending' => $record['end_time'],
- 'firstName' => $record['firstName'],
- 'lastName' => $record['lastName']);
- }
- echo json_encode($arr);
- }
- ////////////////////////////////////////////// Model //////////////////////////////////////////////
- roject.courseDetails = M.Model.create({
- __name__: 'courseDetails',
- usesValidation:NO,
- courseID: M.Model.attr('String', {
- isRequired: YES,
- defaultValue: ''
- }),
- courseName: M.Model.attr('String', {
- isRequired: YES,
- defaultValue: ''
- }),
- roomID: M.Model.attr('String', {
- isRequired: YES,
- defaultValue: ''
- }),
- date: M.Model.attr('String',{
- isRequired: YES,
- defaultValue:''
- }),
- starting: M.Model.attr('String',{
- isRequired: YES,
- defaultValue:''
- }),
- ending: M.Model.attr('String',{
- isRequired: YES,
- defaultValue:''
- }),
- firstName: M.Model.attr('String',{
- isRequired: YES,
- defaultValue:''
- }),
- lastName: M.Model.attr('String',{
- isRequired:YES,
- defaultValue:''
- })
- }, M.DataProviderLocalStorage);
- ////////////////////////////////////////// result returned from the database ///////////////////////
- {"courseID":"WWI10SCC","courseName":"Programming","roomID":"003 A","date":"2011-03-01","starting":"10:00:00","ending":"12:30:00","firstName":"Ralf","lastName":"Mark"}
Add Comment
Please, Sign In to add comment