I have a question about symfony. I’m working on a website and everything was going great, when suddently, without even touching, it all stoped. I narrow it down to a problem in my “getClient” function. Here’s the code: (im using doAuthPlugin if that matters)
in: app/client/lib/myUser.class.php:
public function getClient()
{
$uTemp = $this->getAccount()->getClients()->getFirst();
$userId = $uTemp['_data']['userid'];
$q = Doctrine_Query::create()
->from('Client c')
->where('c.id = ?', $userId);
$result = $q->fetchArray();
if(sizeof($result) > 0){
return $this->getAccount()->getClients()->getFirst();
}else{
return false;
}
}
On the first line, $uTemp == false. Although there is something in $this->getAccount()->getClients().
If someone could shed some light on this, I really suck with Symfony! :p
Thanks!
EDIT:
Here’s get Account:
public function getAccount()
{
if (!$this->user && $id = $this->getAttribute('user_id', null, 'doUser'))
{
$this->user = Doctrine::getTable('User')->find($id);
if (!$this->user)
{
// the user does not exist anymore in the database
$this->signOut();
throw new sfException('The user does not exist anymore in the database.');
}
}
return $this->user;
}
I cannot find getClients, it’s automatically generated by symfony (and since I don’t know symfony that much…)
EDIT 2:
if I do a var_dump on $this->getAccount->getClients(), it’s empty:
object(Client)#123 (18) {
["_node":protected]=>
NULL
["_id":protected]=>
array(0) {
}
["_data":protected]=>
array(14) {
["id"]=>
object(Doctrine_Null)#12 (0) {
}
["userid"]=>
object(Doctrine_Null)#12 (0) {
}
["name"]=>
object(Doctrine_Null)#12 (0) {
}
["firstname"]=>
object(Doctrine_Null)#12 (0) {
}
["phone"]=>
object(Doctrine_Null)#12 (0) {
}
["cellphone"]=>
object(Doctrine_Null)#12 (0) {
}
["postalcode"]=>
object(Doctrine_Null)#12 (0) {
}
["experience"]=>
object(Doctrine_Null)#12 (0) {
}
["connexe"]=>
object(Doctrine_Null)#12 (0) {
}
["formation"]=>
object(Doctrine_Null)#12 (0) {
}
["cv_file"]=>
object(Doctrine_Null)#12 (0) {
}
["is_active"]=>
int(0)
["created_at"]=>
object(Doctrine_Null)#12 (0) {
}
["updated_at"]=>
object(Doctrine_Null)#12 (0) {
}
}
But $this->getAccount does return something
maybe getFirst() doesnt work with fetchArray().
change this for:
maybe this also working with fetchArray():
Sorry, my mistake.
if you use $this->getAccount()->getClients() then also is NULL ? maybe $this->getAccount()->getClients() return NULL ?
UPDATE:
$uTemp = $this->getAccountId(); // (i dont know your schema.yml)
in ClientsTable.class.php:
and next in myUser.class.php you can use:
maybe this also working:
good luck!