Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

The noun specified could not be singularized with insert/update/delete from MySQL

posted by masterix21 8 years ago

Hi,

using flourishlib i got this message after an operation of insert/update/delete with MySQL database:

The noun specified could not be singularized
#0 /Users/masterix21/Sites/project/php/flourish/FORM.php(352): fGrammar::singularize('permessi_utilizzatore')
#1 /Users/masterix21/Sites/project/php/flourish/fActiveRecord.php(1445): fORM::classize('permessi_utilizzatore')
#2 /Users/masterix21/Sites/project/json/Gestore/Edit.php(16): fActiveRecord->delete(false)
#3 /Users/masterix21/Sites/project/json.php(17): include('/Users/masterix...')
#4 {main}

this is my code:

if (fRequest::get('id', 'integer', 0, true) > 0)
    $gestore = new Gestore((fRequest::get('id', 'integer', 0, true)));
else
    $gestore = new Gestore();

if (isset($_GET['delete']) && $_GET['delete']=="Y")
{
        $gestore->delete(FALSE);
      	
		echo fJSON::encode(array(
			"result" => true,
			"code" => 0,
			"msg" => "Record eliminato!",
			"data" => null,
			"count" => 0
		));
    }
    else
    {
        $gestore->populate();
        $gestore->store(false);

        echo fJSON::encode(array(
			"result" => true,
			"code" => 0,
			"msg" => "Salvataggio completato!",
			"data" => null,
			"count" => 0
		));
    }

I'm trying to insert/update/delete from gestore table, but every time i got the upper message!

This is gestore table:

CREATE  TABLE `gestore` (
  `id` INT NOT NULL AUTO_INCREMENT ,
  `attiva` ENUM('Y','N')  NOT NULL DEFAULT 'Y',
  `logo` MEDIUMBLOB NULL ,
  `ragione_sociale` VARCHAR(255) NOT NULL ,
  `indirizzo` TINYTEXT NOT NULL ,
  `cap` VARCHAR(5) NOT NULL ,
  `citta` VARCHAR(70) NOT NULL ,
  `provincia` CHAR(2) NOT NULL ,
  `nazione` VARCHAR(60) NOT NULL ,
  `email` VARCHAR(70) NULL ,
  `telefono` VARCHAR(25) NOT NULL ,
  `fax` VARCHAR(25) NULL ,
  `partita_iva` VARCHAR(13) NULL ,
  `codice_fiscale` VARCHAR(16) NULL ,
  `referente` VARCHAR(90) NULL ,
  `telefono_referente` VARCHAR(25) NULL ,
  `email_referente` VARCHAR(70) NULL ,
  `rappresentante` VARCHAR(90) NULL ,
  `ruolo` VARCHAR(60) NULL ,
  `banca_nome` TEXT NULL ,
  `banca_abi` VARCHAR(5) NULL ,
  `banca_cab` VARCHAR(5) NULL ,
  `banca_cin` CHAR(1) NULL ,
  `banca_cc` VARCHAR(12) NULL ,
  `banca_bban` VARCHAR(23) NULL ,
  `banca_iban` VARCHAR(34) NULL ,
  `banca_bic` VARCHAR(11) NULL ,
  `banca_sia` VARCHAR(5) NULL ,
  `max_aziende` INT NOT NULL DEFAULT 0,
  `max_punti_vendita` INT NOT NULL DEFAULT 0,
  `max_card` INT NOT NULL DEFAULT 0,
  `limite_punti` BIGINT(11)  NOT NULL DEFAULT 0 ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB

and this is permessi_utilizzatore table:

CREATE  TABLE `permessi_utilizzatore` (
  `permesso_id` INT NOT NULL ,
  `gestore_id` INT NULL ,
  `azienda_id` INT NULL ,
  `punto_vendita_id` INT NULL ,
  `utente_id` INT NULL ,
  INDEX `fk_gestore_has_permesso_permesso1` (`permesso_id` ASC) ,
  INDEX `fk_gestore_has_permesso_gestore1` (`gestore_id` ASC) ,
  INDEX `fk_permessi_utilizzatore_punto_vendita1` (`punto_vendita_id` ASC) ,
  INDEX `fk_permessi_utilizzatore_azienda1` (`azienda_id` ASC) ,
  INDEX `fk_permessi_utilizzatore_utente1` (`utente_id` ASC) ,
  CONSTRAINT `fk_gestore_has_permesso_gestore1`
    FOREIGN KEY (`gestore_id` )
    REFERENCES `gestore` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_gestore_has_permesso_permesso1`
    FOREIGN KEY (`permesso_id` )
    REFERENCES `permesso` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_permessi_utilizzatore_punto_vendita1`
    FOREIGN KEY (`punto_vendita_id` )
    REFERENCES `punto_vendita` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_permessi_utilizzatore_azienda1`
    FOREIGN KEY (`azienda_id` )
    REFERENCES `azienda` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_permessi_utilizzatore_utente1`
    FOREIGN KEY (`utente_id` )
    REFERENCES `utente` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB

Thank you

The ORM for Flourish uses fGrammar to perform the singularization and pluralization of nouns for the purpose of mapping classes to tables. By default I ship an implementation that only handles English since I do not know any other languages, and there was an algorithm I was able to use as a base. It appears that the English singular <-> plural rules aren't working for your table names.

The options to fix this are to use fORM::mapClassToTable() if you just need the fix for this ORM action, or fGrammar::addSingularPluralRule() if you need a more general fix.

posted by wbond 8 years ago