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

Get usage count of foreign key

$
0
0

Hi,

I have this file called table.ref.php that sets up the editor for my list of references (as in journal articles) in table 'ref' like so:

// 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;

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'ref', 'id' )
    ->fields(
        Field::inst( 'id' ),
        Field::inst( 'author' ),
        Field::inst( 'year' ),
        Field::inst( 'title' ),
        Field::inst( 'journal' ),
        Field::inst( 'etcetera' ),
        Field::inst( 'count' )->getValue( 9 ),
        Field::inst( 'user' )
    )
    ->where( 'user', $_SESSION['user'] )
    ->process( $_POST )
    ->json();

Now for the field 'count' I would like to return the number of times each reference is used in another table called 'cases'. Each case only ever has one reference, but one reference can be used for multiple cases. Is there an easy way to replace the number 9 in above code snippet with the actual number of cases that the reference is cited for?


Viewing all articles
Browse latest Browse all 81728

Trending Articles



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