Newbie: can"t access a return value.

Newbie: can"t access a return value.

am 01.08.2009 18:13:09 von talofo talofo

Hi all,

When I do this:
$associacao_dao->listar($limit, $offset);

I can var_dump the correct $limit.
I can var_dump the correct $offset.

I CAN'T access the object that I was hoping to get, called $records.

After this, I was hoping to do var_dump($records); and see the stdClass
object.=20




Here is the listar method:

public function listar($limit=3Dnull, $offset=3Dnull)=20
{
$query_str=3D"SELECT * FROM associacao";
=09
$stmt =3D $this->_dbh->prepare($query_str . ' LIMIT ?, ?');
$stmt->bindParam(1, $limit, PDO::PARAM_INT);
$stmt->bindParam(2, $offset, PDO::PARAM_INT);
=09
$stmt->execute();
=09
$records =3D $stmt->fetchAll(PDO::FETCH_OBJ);
=09
return $records; =09
}



Any help will be greatly appreciated.


Thanks a lot in advance,
M=E1rcio


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Newbie: can"t access a return value.

am 01.08.2009 18:41:43 von talofo talofo

Solved. Forget to assigning the return value of the method to anything. =
:S
Sorry.

M=E1rcio

> -----Original Message-----
> From: MEM [mailto:talofo@gmail.com]
> Sent: s=E1bado, 1 de Agosto de 2009 17:13
> To: 'php-general@lists.php.net'
> Subject: Newbie: can't access a return value.
>=20
> Hi all,
>=20
> When I do this:
> $associacao_dao->listar($limit, $offset);
>=20
> I can var_dump the correct $limit.
> I can var_dump the correct $offset.
>=20
> I CAN'T access the object that I was hoping to get, called $records.
>=20
> After this, I was hoping to do var_dump($records); and see the =
stdClass
> object.
>=20
>=20
>=20
>=20
> Here is the listar method:
>=20
> public function listar($limit=3Dnull, $offset=3Dnull)
> {
> $query_str=3D"SELECT * FROM associacao";
>=20
> $stmt =3D $this->_dbh->prepare($query_str . ' LIMIT ?, ?');
> $stmt->bindParam(1, $limit, PDO::PARAM_INT);
> $stmt->bindParam(2, $offset, PDO::PARAM_INT);
>=20
> $stmt->execute();
>=20
> $records =3D $stmt->fetchAll(PDO::FETCH_OBJ);
>=20
> return $records;
> }
>=20
>=20
>=20
> Any help will be greatly appreciated.
>=20
>=20
> Thanks a lot in advance,
> M=E1rcio


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Newbie: can"t access a return value.

am 01.08.2009 18:42:07 von Trevor Gryffyn

Try: $records =3D $associacao_dao->listar($limit, =
$offset); -TG ----- Original Message =
----- From: "MEM" To: =
Date: Sat, 1 Aug 2009 17:13:09 =
+0100 Subject: [PHP] Newbie: can't access a return =
value. > Hi all, > > When I do this: > =
$associacao_dao->listar($limit, $offset); > > I can var_dump =
the correct $limit. > I can var_dump the correct $offset. > =
> I CAN'T access the object that I was hoping to get, called =
$records. > > After this, I was hoping to do =
var_dump($records); and see the stdClass > object. > > =
> > > Here is the listar method: > > public =
function listar($limit=3Dnull, $offset=3Dnull) > { > =
$query_str=3D"SELECT * FROM associacao"; > > $stmt =3D =
$this->_dbh->prepare($query_str . ' LIMIT ?, ?'); > =
$stmt->bindParam(1, $limit, PDO::PARAM_INT); > $stmt->bindParam(2, =
$offset, PDO::PARAM_INT); > > $stmt->execute(); > =
> $records =3D $stmt->fetchAll(PDO::FETCH_OBJ); > =
> return $records; > } > > > > Any =
help will be greatly appreciated. > > > Thanks a lot in =
advance, > M=E1rcio > > > -- > PHP General =
Mailing List (http://www.php.net/) > To unsubscribe, visit: =
http://www.php.net/unsub.php > >

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php