Bonjour
@ epommate2: j'ai regardé la doc là:
http://api.joomla.org/Joomla-Framework/Database/JDatabase.html#methodinsertObject
@ devlop78
echo $nb ne retourne rien, enfin rien ne s'affiche à la validation du formulaire.
J'ai modifié un peu mon code;je vous le met en entier car maintenant, je n'ai même plus l'insertion dans la table:
function store( $updateNulls=false )
{
$acl =& JFactory::getACL();
$section_value = 'users';
$k = $this->_tbl_key;
$key = $this->$k;
$class_vars = get_object_vars($this);
foreach ($class_vars as $name => $value)
{
if(strpos($name, "sofiom_") !== false)
{
$value = mb_strtoupper($value,'UTF-8');
$this->$name = $value;
}
}
$this->name = mb_strtoupper($this->name,'UTF-8');
$this->email = mb_strtoupper($this->email,'UTF-8');
if ($key)
{
// existing record
$ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, updateNulls );
// syncronise ACL
$object_id = $acl->get_object_id( $section_value, $this->$k, 'ARO' );
$groups = $acl->get_object_groups( $object_id, 'ARO' );
$acl->del_group_object( $groups[0], $section_value, $this->$k, 'ARO' );
$acl->add_group_object( $this->gid, $section_value, $this->$k, 'ARO' );
$acl->edit_object( $object_id, $section_value, $this->_db-getEscaped( $this->name ), $this->$k, 0, 0, 'ARO' );
}
else
{
// new record
$ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key );
// syncronise ACL
$acl->add_object( $section_value, $this->name, $this->$k, null, null, 'ARO' );
$acl->add_group_object( $this->gid, $section_value, $this->$k, 'ARO' );
//my_mail - membre non-cotisant par défaut
$this->catuse = 2;
$this->name = mb_strtoupper($this->name,'UTF-8');
$this->email = mb_strtoupper($this->email,'UTF-8');
$add = $this->_db->insertObject('#__mm_users',$this, $this->_tbl_key);
}
}
Je me demande si je passe bien mes paramètres. Je ne vois pas pourquoi ça fonctionne pour les tables jos_users et les tables ACL mais pas pour la table jos_mm_users (liée au composant MyMail). Cette table comprends 4 champs:
niduse int(11) --> en auto-increment
catuse int(11) --> à mettre à la valeur 2
namuse varchar(50) --> nom de l'utilisateur
emause varchar(50) --> mail de l'utilisateur
A priori, le $this devrait fonctionner car j'ai bien les 3 champs imposés et normalement, le 1er champ en auto-increment se modifie tout seul. Ai-je raté qqch???
Merci d'avance de votre aide