<?php

/*
 * Editor server script for DB table Events
 * Created by http://editor.datatables.net/generator
 */

// DataTables PHP library and database connection
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;

// The following statement can be removed after the first run (i.e. the database
// table has been created). It is a good idea to do this to help improve
// performance.

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'EventLocations', 'locationId' )
    ->fields(
        Field::inst( 'eventId' ), // Foreign key to link with the Events table
        Field::inst( 'EventLocations.locationName' )
            ->validator( Validate::notEmpty() )
            ->validator( Validate::minMaxLen( 3, 80 ) ),
        Field::inst( 'EventLocations.locationMapUrl' ),
        Field::inst( 'EventLocations.eventId' )
            
    )
   	    ->join(
	    Mjoin::inst( 'Events' )
	       ->link( 'Events.eventId', 'EventLocations.eventId' )
	      	->fields(
	      	    	Field::inst( 'eventId' )
	      	    	
	
		
	)
	    )
	->process($_POST)
    ->json();






