FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Multidimensional Arrays
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Multidimensional Arrays [message #180409] Mon, 11 February 2013 20:00 Go to previous message
Rita Ferreira is currently offline  Rita Ferreira
Messages: 4
Registered: February 2013
Karma:
Junior Member
Hi,
I need some help with multidimensional arrays, if possible.

I have 3 classes, one to acces to DB called config, another called NoticiasController and another called Noticias and the index.php.

On index, I'm creating an object of NoticiasController and calling the method listar().
On NoticiasController I have an object of config and there on config I query the DB like this:

SELECT id, noticia FROM NOTICIAS;

On the config I only have a mysql_query command.

Then on NoticiasController I'm trying to manage the data returned by that query, and here's problem :S

I'm doing something like this:

NoticiasController.php

public function listar()
{

require_once "../config.php";
require_once'/Models/Noticia.php';

$a=new config();
$sql="SELECT id_noticia, corpo_noticia FROM Noticias";
$res=$a->listar($sql);

$e=array();

while ($row = mysql_fetch_assoc($res))
{
$temp=new Noticia($row["id_noticia"],$row["corpo_noticia"]);
$e[]=$temp; <------------ here is the problem
?> <br /> <?php
}


return $e;
}

Noticia.php
(…)
public function __construct($Id_Noticia, $Corpo_Noticia)
{
$this->Id_Noticia = $Id_Noticia;
$this->Corpo_Noticia = $Corpo_Noticia;
}


public function getCorpoNoticia(){
return $this->Id_Noticia;
}
(…)


My goal is to insert on $e every object of Noticia for then send it to index and print the values but when I try to do it I got the error "Fatal error: Call to a member function getCorpoNoticia() on a non-object in /NoticiaController ".

Can you help me? I'm having lots of problems working with arrays and I've tried another ways to do this but I have never reach what I want.

Thanks :)
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: P = NP in Binary Portrait
Next Topic: Connection with Sql server on Windows
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 08:50:37 GMT 2024

Total time taken to generate the page: 0.06780 seconds