Raw SQL

Raw SQL

xain819xain819 Posts: 15Questions: 4Answers: 1

how can i use Raw SQL to out put it in my Table im using the editor

my RawSql is something like this(iknow its wrong :) ):

$result = $db
    ->sql("SELECT * from pcc_schedulelist s,pcc_login l,pcc_courses c WHERE l.studid= c.department AND (s.courseid=c.courseid || s.courseid='15') AND c.department='1' GROUP BY schedid ORDER BY s.toCourse ")
    ->process($_POST)
    ->data();

and my serverSided script is which i dont know how to implement the code above :

Editor::inst( $db, 'pcc_schedulelist', 'schedid' )
    ->fields(
        Field::inst( 'pcc_schedulelist.schedid' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'pcc_schedulelist.courseid' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'pcc_schedulelist.coursecode' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'pcc_schedulelist.courseno' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'pcc_schedulelist.description' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'pcc_schedulelist.totalunits' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'pcc_schedulelist.days' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'pcc_courses.courseid' ),
        Field::inst( 'pcc_courses.department' ),
        Field::inst( 'pcc_login.studid' ),
        Field::inst( 'pcc_schedulelist.start' )->validator( 'Validate::notEmpty' )
        ->getFormatter( function ($val) {
                return date( 'h:i A', $val );
              } ) ->validator( 'Validate::notEmpty' ),
        Field::inst( 'pcc_schedulelist.end' )->validator( 'Validate::notEmpty' )
        ->getFormatter( function ($val) {
                return date( 'h:i A', $val );
              } ) ->validator( 'Validate::notEmpty' ),
        Field::inst( 'pcc_schedulelist.room' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'pcc_schedulelist.section' )->validator( 'Validate::notEmpty' )
     )
    ->leftJoin( 'pcc_courses', 'pcc_courses.courseid', '=', 'pcc_schedulelist.courseid' )
    ->leftJoin( 'pcc_login', 'pcc_login.studid', '=', 'pcc_courses.department' )
    ->where( $key = 'pcc_courses.department', $value = $id, $op = '='  )
    // ->where( $key = 'pcc_schedulelist.courseid', $value = '15', $op = '='  )
    ->process( $_POST )
    ->json();

now how can i implement the raw SQL to my Editor so that i can display it in my table?

This discussion has been closed.