Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82821

Parent Child example, issue with prefixing field .id with table name

$
0
0

I have implemented the parent-child-editing example on my own system using the Editor-PHP-2.3.2 libraries and it works perfectly. I have run into an issue that seems to prevent me from adding a leftJoin to my main table.

I'm using MySQL for an app that keeps track of rolls of film (main table) and a secondary table that tracks individual frames for each roll (prints).

The functionality works just fine until I attempt to include a leftJoin, then things break. Interestingly, an error is returned that tells me that you always have to include the table name AND field name, and this makes sense, and it's also plainly visible on your site. However, in your example under Server Site PHP code for the parent table, you're not doing that for the paren's .id field. And indeed without the table name, the parent/child editing functions perfectly for me. When the table name is added, no errors show, but the parent/child functionality disappears. And without the table name, and with my leftJoin, no data appears in the child table. Obviously I"m missing something. Here is the relevant PHP Server Site code:

$editor = Editor::inst( $db, 'tpa' )             // tpa is the parent table
    ->field(
        Field::inst( 'id')->set( false ),            //  <------ issue 

        Field::inst( 'tpa.no')->validator( 'Validate::notEmpty' ),
        Field::inst( 'tpa.year'),
        Field::inst( 'tpa.month'),
        Field::inst( 'tpa.notes'),

        Field::inst( 'tpa.format_no')            
            ->options( Options::inst()
                ->table('format_table')          // Formats, like 35mm, 120, etc.
                ->value('id')
                ->label('format_text') 
            )
            ->setFormatter( Format::ifEmpty( null) )
            ->validator( Validate::dbValues() ),  // Makes a nice pick list
        Field::inst( 'format_table.format_text')   
    
    )       
    ->join(
        MJoin::inst( 'prints')                    // prints is the secondary table. 
        ->link( 'tpa.id', 'prints.roll_id')
        ->field(
            Field::inst( 'prints.id' )
        )       
    )
   ->leftJoin( 'format_table', 'format_table.id', '=', 'tpa.format_no')

There are other leftJoins I would like to include.


Viewing all articles
Browse latest Browse all 82821

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>