Closed back-2-95 closed 11 years ago
Look at ZfcUser\Mapper\User.
Yes I looked at it, but how to change name of the database? I wouldn't want to create new module just to overwrite that mapper...
As I understand, new module is only one way to overwrite smth. And later you might want to overwrite not only table name. ZfcUser provides only generic functionality.
You need to edit the $tableName on around line 11.
I found that, but I'd prefer configuration. =)
I think you find a solution but you have to make a custom user mapper : in the Module.php of YOUR module pu that in the factories :
'zfcuser_user_mapper' => function ($sm) { $options = $sm->get('zfcuser_module_options'); $mapper = new \MyCollaborateurs\Mapper\Collaborateurs() ; $mapper->setDbAdapter($sm->get('zfcuser_zend_db_adapter')); $entityClass = $options->getUserEntityClass(); $mapper->setEntityPrototype(new $entityClass); $mapper->setHydrator(new \MyCollaborateurs\Mapper\MyCollaborateursHydrator()); return $mapper; },
And create the file Collaborateurs into the correct directory here : src/MyCollaborateus\mapper\ This file have to extends \ZfcUser\Mapper\User and know add the property :
protected $tableName = 'collaborateur';
As mentioned, simply extend the User mapper and change the $tableName property... It should only take a couple of seconds. I'm not sure if setting all these in configuration is really worth it. That said, if the PR was done and no one was opposed to it, we could look at getting it merged.
How to change table name 'user' to something else? In \ZfcUser\Mapper\User
protected $tableName = 'test';
but it's display an error message Please anyone help me with explanation I am beginner in ZF
When i change table name from "user" to something else. It doesn't reflact query with new table name and still seems with old table name. Please let me know the right way to change table name.
As EvanDotPro states: "As mentioned, simply extend the User mapper and change the $tableName property... It should only take a couple of seconds. I'm not sure if setting all these in configuration is really worth it. That said, if the PR was done and no one was opposed to it, we could look at getting it merged."
Hi Danielss89, Thanks for your quite reply. I've already replaced the vaiable's "$tableName" value with my new table name, but didn't get any luck and result was same. After few hours research I found solution. There is a file named "ZfcUserDoctrineORM.Entity.User.dcm.xml" in which table name is manualy define. Below is the code of that file : <?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="ZfcUserDoctrineORM\Entity\User" table="user">
</entity>
After making changes in this file,I got the correct result.
Yes, thats another case, Then your question should be in that repository and not this :)
Actually, you don't even need a mapper, just modify:
ZfcUser/Options/ModuleOptions.php [103]
protected $tableName = 'users';
@kouafi It's very bad practice to modify core files.
I cannot find tablename setting on config?
br, Marko