join not working

join not working

whitbaconwhitbacon Posts: 40Questions: 2Answers: 0
edited May 2013 in General
THis returns error 500

[code]
<?php

/*
* Editor server script for DB table caseinfo
* Automatically generated by http://editor.datatables.net/generator
*/

// DataTables PHP library
include( "lib/DataTables.php" );

// Alias Editor classes so they are easy to use

use DataTables\Editor;
use DataTables\Editor\Field;
use DataTables\Editor\Format;
use DataTables\Editor\Join;
use DataTables\Editor\Validate;


// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'caseinfo' )
->fields(
Field::inst( 'casename' ),
Field::inst( 'casetype' ),
Field::inst( 'factsnum' ),
Field::inst( 'socialsecurity' )
->validator( 'Validate::maxLen', 4 ),
Field::inst( 'primdob' )
->validator( 'Validate::dateFormat', 'D, j M y' )
->getFormatter( 'Format::date_sql_to_format', 'D, j M y' )
->setFormatter( 'Format::date_format_to_sql', 'D, j M y' ),
Field::inst( 'id' ),
Field::inst( 'userid' ),
Field::inst( 'agencyid' )
)
->join(
Join::inst( 'users', 'object' )
->join( 'userid','member_id' )
->field(
Field::inst( 'fname' )
)
//->where($a, $b, $c)

->process( $_POST )
->json();

?>
[/code]

I also notice in this documentation you tend to use

->field ()

->fields()

interchangeably.
http://editor.datatables.net/tutorials/php_join
Am I missing something ?

Replies

  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin
    What does your server error log say? A 500 error is very generic and doesn't really say what the problem would be.

    Thanks,
    Allan
  • whitbaconwhitbacon Posts: 40Questions: 2Answers: 0
    HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
  • whitbaconwhitbacon Posts: 40Questions: 2Answers: 0
    this does work however
    [code]
    Editor::inst( $db, 'caseinfo' )
    ->fields(
    Field::inst( 'casename' ),
    Field::inst( 'casetype' ),
    Field::inst( 'factsnum' ),
    Field::inst( 'socialsecurity' )
    ->validator( 'Validate::maxLen', 4 ),
    Field::inst( 'primdob' )
    ->validator( 'Validate::dateFormat', 'D, j M y' )
    ->getFormatter( 'Format::date_sql_to_format', 'D, j M y' )
    ->setFormatter( 'Format::date_format_to_sql', 'D, j M y' ),
    Field::inst( 'id' ),
    Field::inst( 'userid' ),
    Field::inst( 'agencyid' )
    )

    //->where($a, $b, $c)

    ->process( $_POST )
    ->json();


    /* ->join(
    Join::inst( 'users', 'object' )
    ->join( 'userid','member_id' )
    ->fields(
    Field::inst( 'fname' )
    ) */
    ?>

    [/code]
  • whitbaconwhitbacon Posts: 40Questions: 2Answers: 0
    missing a closing paren

    [code]
    ->join(
    Join::inst( 'users', 'object' )
    ->join( 'userid','member_id' )
    ->fields(
    Field::inst( 'fname' )
    )
    [/code]

    needed to be

    [code]
    ->join(
    Join::inst( 'users', 'object' )
    ->join( 'userid','member_id' )
    ->fields(
    Field::inst( 'fname' )
    )
    )
    [/code]
  • whitbaconwhitbacon Posts: 40Questions: 2Answers: 0
    However, I would still like the field vs fields questions answered
  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin
    [quote]
    I also notice in this documentation you tend to use

    ->field ()

    ->fields()

    interchangeably.
    [/quote]

    No you aren't missing anything - they are identical. The intention was that `field()` would be used to add a single field, while `fields()` would be used to add multiple fields with a single function call, but under the hood they are identical:

    http://editor.datatables.net/docs/current/php/class-DataTables.Editor.html#_field

    In DataTables 1.10, there will be `row()` and `rows()` for working on a single row, or multiple rows. These will not be identical, so plural does have meaning :-).

    Allan
This discussion has been closed.