WHERE clause issue

WHERE clause issue

doctorjnupedoctorjnupe Posts: 21Questions: 6Answers: 1

I have the following code and I do not understand why the editor is not displaying the results. I am not getting any errors.
Editor::inst( $db, 'SYSTEM_ANNOTATION' ) ->fields( Field::inst( 'nist_id' ), Field::inst( 'nist_inherited_control' ), Field::inst( 'nist_inherited_from_whom' ), Field::inst( 'nist_control_design' ), Field::inst( 'nist_design_effectivness' ), Field::inst( 'nist_design_sup_document' ), Field::inst( 'nist_des_sup_doc_name' ), Field::inst( 'nist_operational_test' ), Field::inst( 'nist_op_effectivness' ), Field::inst( 'nist_op_sup_doc' ), Field::inst( 'nist_op_sup_doc_name' ), Field::inst( 'nist_overall_pf' ), Field::inst( 'nist_notes' ), Field::inst( 'nist_corrective_action' ), Field::inst( 'nist_documentation' ), Field::inst( 'family' ), Field::inst( 'ctrl_id' ), Field::inst( 'rmf_name' ), Field::inst( 'assessment_procedure_number' ), Field::inst( 'cci_number' ), Field::inst( 'cci_definition' ), Field::inst( 'implementation_guidance' ), Field::inst( 'validation_procedure' ), Field::inst( 'compelling_evidence' ) ) ->where('system_name', '$current_system') ->where('system_id', $systemid) ->process( $_POST ) ->json();

Here is the XHR data:
current_system:Yess5
systemid:'2017-062d9'

This question has an accepted answers - jump to answer

Answers

  • doctorjnupedoctorjnupe Posts: 21Questions: 6Answers: 1
    Editor::inst( $db, 'SYSTEM_ANNOTATION' )
        ->fields(
          Field::inst( 'nist_id' ),
          Field::inst( 'nist_inherited_control' ),
          Field::inst( 'nist_inherited_from_whom' ),
          Field::inst( 'nist_control_design' ),
          Field::inst( 'nist_design_effectivness' ),
          Field::inst( 'nist_design_sup_document' ),
          Field::inst( 'nist_des_sup_doc_name' ),
          Field::inst( 'nist_operational_test' ),
          Field::inst( 'nist_op_effectivness' ),
          Field::inst( 'nist_op_sup_doc' ),
          Field::inst( 'nist_op_sup_doc_name' ),
          Field::inst( 'nist_overall_pf' ),
          Field::inst( 'nist_notes' ),
          Field::inst( 'nist_corrective_action' ),
          Field::inst( 'nist_documentation' ),
          Field::inst( 'family' ),
          Field::inst( 'ctrl_id' ),
          Field::inst( 'rmf_name' ),
          Field::inst( 'assessment_procedure_number' ),
          Field::inst( 'cci_number' ),
          Field::inst( 'cci_definition' ),
          Field::inst( 'implementation_guidance' ),
          Field::inst( 'validation_procedure' ),
          Field::inst( 'compelling_evidence' )
        )
        ->where('system_name', '$current_system')
        ->where('system_id', $systemid)
        ->process( $_POST )
        ->json();
    
    
  • doctorjnupedoctorjnupe Posts: 21Questions: 6Answers: 1

    Re-posted Editor info to add markdown.

  • allanallan Posts: 63,480Questions: 1Answers: 10,467 Site admin
    Answer ✓

    In PHP '$current_system' is a literal string. e.g. it is searching for $current_system as a string - not what that variable might contain.

    PHP will only do variable expansion in double quoted strings. Although having said that, you don't actually need any quotes here - just use:

    ->where('system_name', $current_system)
    

    The PHP documentation for strings can be found here.

    Allan

This discussion has been closed.