Skip to content

EntitySingular Ignoring a few tables & disabling

Philip Michael Raab edited this page Jun 26, 2014 · 2 revisions

Here the basics in EntitySingular.

By default if a table name ends in an 's', the DataTable keeps it BUT the entity loses it.

Basically the DataTable has access to All the individual entities to plural, entity singular.

E.G.

Table: users
DataTable: TableUsers
Entity: User

But you can customise this as bellow:

// First we create a NameManger
$nm = new NameManager('DBLayer');
	
// EntitySingular is enabled by default
// To check the status use:
if ($nm->entitySingular()) {
	// If enabled
	// To disable it:
    $nm->entitySingular(false);
} else {
	// If disabled
    // To disable it:
    $nm->entitySingular(true);
}
	
// Lets keep it enabled
$nm->entitySingular(true);
	
// But lets tell it that a few tables ending in 's' should be ignored
// To reset the ignore list pass FALSE
$nm->setEntitySingularIgnores(false);

// Now lets add our ignore tables
// adding cities
$nm->setEntitySingularIgnores('cities');
// you can add them as an array or | delimited string as well
$nm->setEntitySingularIgnores('cities|smartees');
// OR
$nm->setEntitySingularIgnores(array('cities','smartees'));
	
// Righty let var_dump and we should have array('cities','smartees')
var_dump($nm->getEntitySingularIgnores());