Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8348

Re: Multidimensional Arrays

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: Multidimensional Arrays
Date 2013-02-11 17:29 -0500
Organization A noiseless patient Spider
Message-ID <kfbra9$2ct$1@dont-email.me> (permalink)
References <5635299c-b6a1-4e75-bf8e-1b4f774b2702@googlegroups.com>

Show all headers | View raw


On 2/11/2013 3:00 PM, Rita Ferreira wrote:
> 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 :)
>

What's your actual code and where are you getting the error?  The error 
you indicated will not occur on the like you pointed out.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Multidimensional Arrays Rita Ferreira <ritaferreira83@gmail.com> - 2013-02-11 12:00 -0800
  Re: Multidimensional Arrays Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-11 17:29 -0500
  Re: Multidimensional Arrays Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-13 10:58 +0100

csiph-web