get( 'ST', Records::class . '_schema_installed' ) ) { $wpdb->query( sprintf( Records::$string_batch_sql_prototype, $wpdb->prefix ) ); $option->set( 'ST', Records::class . '_schema_installed', true ); } } ); Records::curryN( 'get', 2, function ( \wpdb $wpdb, $batchId ) { return $wpdb->get_col( $wpdb->prepare( "SELECT string_id FROM {$wpdb->prefix}icl_string_batches WHERE batch_id = %d", $batchId ) ); } ); Records::curryN( 'set', 3, function ( \wpdb $wpdb, $batchId, $stringId ) { // TODO: ignore duplicates $wpdb->insert( "{$wpdb->prefix}icl_string_batches", [ 'batch_id' => $batchId, 'string_id' => $stringId, ], [ '%d', '%d' ] ); } ); Records::curryN( 'findBatch', 2, function ( \wpdb $wpdb, $stringId ) { return $wpdb->get_var( $wpdb->prepare( "SELECT batch_id FROM {$wpdb->prefix}icl_string_batches WHERE string_id = %d", $stringId ) ); } ); Records::curryN( 'findBatches', 2, function ( \wpdb $wpdb, $stringIds ) { $in = wpml_prepare_in( $stringIds, '%d' ); $data = $wpdb->get_results( "SELECT batch_id, string_id FROM {$wpdb->prefix}icl_string_batches WHERE string_id IN ({$in})" ); $keyByStringId = Fns::converge( Lst::zipObj(), [ Lst::pluck( 'string_id' ), Lst::pluck( 'batch_id' ) ] ); return $keyByStringId( $data ); } );