increment number

something like that...
I'm sorry but I'm not that good ..

$db = FabrikWorker::getDbo();
$query = $db->getQuery(true);
$query
->select('coalasce(max(numero_pratica),0 +1')
->from($db->quoteName('movimenti'));
$db->setQuery($query);
$count = $db->loadResult();
return $count;
$ formModel-> data ['movimenti___numero_pratica'] = $count;
 
You:
$ formModel-> data ['movimenti___numero_pratica'] = $count;
PHP:
Code:
$formModel->data['movimenti___numero_pratica'] = $count;
This time I had to remove "only" three spaces, but they're equally important. Please learn at least the basics of PHP, we here can't always fix it for you. Thank you.

Other than that, I'm not sure this will do what you expect it to do, but you'll find out.
 
If I correctly understand your english you like to increment number for your "center field". So you have in table 3 ABC and add new ABC you have now 4 ABC?

Then you should count "center field" + 1
Maybe something like this
PHP:
$centro = '{movimenti___centro_raw}';
if ($centro != ''){
    $db = FabrikWorker::getDbo();
    $query = $db->getQuery(true);
    $query
        ->select('COUNT(*)')
        ->from($db->quoteName('movimenti'))
        ->where($db->quoteName('centro') . ' = ' . $db->quote($centro));
    $db->setQuery($query);
    $count = $db->loadResult();

    if ($count == '' || $count == 0){
        return 1;
    }
    else {
        return $count + 1;
    }
}
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top