request unknown parameters, when i inspect in developer tools , i see more rows than expecting

request unknown parameters, when i inspect in developer tools , i see more rows than expecting

crcucbcrcucb Posts: 25Questions: 8Answers: 0

I am trying to add a nested join and I am getting this: DataTables warning: table id=Adresses- Requested unknown parameter '15' forrowo, column 15. For more information about this error, please see http://datatables.net/tn/4

I counter the columns and everything seems correct.
I am following the Joinarray.php example, here is my php:

<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');

$file = fopen("../app_data/newfile.txt", "w") or die("Unable to open file!");

if ($file) {

    $jsonArray = json_encode( $_POST);

fwrite($file, $jsonArray); // Write the captured output to the file
fclose($file); // Close the file

}

/*
* Editor server script for DB table Adresses
* Created by http://editor.datatables.net/generator
*/

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

// $debug = [];
//$db->debug( function ( $mess ) use ( &$debug ) {
// $debug[] = $mess;
//} );

// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;

//SELECT ADR.AddressAID, ADR.StreetName, ADR.AddressNumber, ADR.Address2, ADR.City, ADR.State, ADR.Zip, ADR.Ward, ADR.District, ADR.AddressNotes, ADR.NorS, ADR.Lat, ADR.Long, ADR.AddressInactive,
// vw_AdrNames.Names
//FROM Addresses AS ADR LEFT OUTER JOIN
// view_Address_LastNames AS vw_AdrNames ON ADR.AddressAID = vw_AdrNames.AddressAID

// Build our Editor instance and process the data coming from _POST

Editor::inst( $db, 'Addresses', 'AddressAID' )

->fields(

    Field::inst( 'Addresses.streetname' ),
    Field::inst( 'Addresses.addressnumber' ),
    Field::inst( 'Addresses.address2' ),
    Field::inst( 'Addresses.city' ),
    Field::inst( 'Addresses.state' ),
    Field::inst( 'Addresses.ward' ),
    Field::inst( 'Addresses.district' ),
    Field::inst( 'Addresses.addressnotes' ),
    Field::inst( 'Addresses.nors' ),
    Field::inst( 'Addresses.lat' ),
    Field::inst( 'Addresses.long' ),
    Field::inst( 'Addresses.addressinactive' ),
    Field::inst( 'Addresses.AddressAID')
  ->options(
            Options::inst()
                ->table('view_AddressNames')
                ->value('AddressAID')
                ->label('Names')
        )
       ,
    Field::inst('view_AddressNames.Names')
  ->options(
            Options::inst()
                ->table('vew_AddressPartyCount')
                ->value('AddressAID')
                ->label('Parties')
        )
        ,
    Field::inst('vew_AddressPartyCount.Parties')  
)
->where( 'Addresses.AddressAID', 2, '<' )
->leftJoin('view_AddressNames', 'view_AddressNames.AddressAID', '=', 'Addresses.AddressAID')
->leftJoin('vew_AddressPartyCount', 'vew_AddressPartyCount.AddressAID', '=', 'Addresses.AddressAID')
->join(
    Mjoin::inst( 'view_Residents' )
        ->link( 'Addresses.AddressAID', 'view_Residents.ResidentAddressAID' )
        ->order( 'FullName asc' )
        ->fields(
            Field::inst( 'ResidentAddressAID' )
                ->options( Options::inst()
                    ->table( 'view_Residents' )
                    ->value( 'ResidentAddressAID' )
                    ->label( 'FullName' )
                ),
            Field::inst( 'FullName' )
        )
    )

->debug(true) // Add this line
->process( $_POST )

->json();

I added a where so its only returning 1 record., When I revewi the response in web developer tools, I see a lot more data than expecting: aafter the residents, it's just a liat if all reaidents in the database.

{"data":[{"DT_RowId":"row_46","Addresses":{"streetname":"AARBY RD","addressnumber":"10","address2":"","city":"my city","state":"AL","ward":"10","district":"1","addressnotes":"These are my address notes","nors":"","lat":"42.08923300","long":"-76.83152000","addressinactive":"0","AddressAID":"46"},"view_AddressNames":{"Names":" Doe"},"vew_AddressPartyCount":{"Parties":"R3B0U0D0"},"view_Residents":[{"ResidentAddressAID":"46","FullName":"Doe, Kane H"}]}],"options":{"Addresses.AddressAID":[{"label":"","value":"321"},{"label":"","value":"684"},{"label":"","value":"269"},{"label":"","value":"3872"},{"label":"","value":"2434"},{"label":"","value":"6005"},{"label":"","value":"4853"},{"label":"","value":"5028"},{"label":"","value":"403"},{"label":"","value":"9785"},{"label":"","value":"955"},{"label":"","value":"5556"},{"label":"","value":"3000"},{"label":"","value":"983"},{"label":"","value":"3214"},{"label":"","value":"3385"},{"label":" Doe","value":"46"},{"label":"ABBEY","value":"3489"},{"label":"ABBEY","value":"3765"},{"label":"ABBEY,BOLLINGER","value":"5143"},{"label":"ABBOTT,WEIBRECHT","value":"3149"},{"label":"ABDUL MALIK,ALI,MALIK,WAS","value":"1152"},{"label":"ABERNATHY","value":"811"},{"label":"ABPLANALP","value":"3232"},{"label":"ACCARDI","value":"3210"},

Answers

  • crcucbcrcucb Posts: 25Questions: 8Answers: 0

    Here is the other php for residents:

    <?php

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

    // Alias Editor classes so they are easy to use
    use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate,
    DataTables\Editor\ValidateOptions;
    /*
    * Example PHP implementation used for the join.html example
    */
    Editor::inst( $db, 'view_Residents' )
    ->field(
    Field::inst( 'ResidentAddressAID' )->set(false),
    Field::inst( 'FullName' )
    )
    ->process($_POST)
    ->json();

Sign In or Register to comment.