Object Array
Posted: Mon Jun 28, 2010 11:38 am
Hi there,
I need an help to do something that in java is working well... but in php gives me some problems.
So:
I create a class to define an object.
In another class I retrive values from DB
then i html page
in the row.
It seems that obj1 lose the the identity of an object and so I can`t use the get method.
Thanks
I need an help to do something that in java is working well... but in php gives me some problems.
So:
I create a class to define an object.
Code: Select all
class object1{
var property;
function getProperty...
function setProperty...
}Code: Select all
class showListDocuments {
var $allDocuments = array ();
function getDB() {...}
function listDocuments() {
$documents = $db->selectQuery($database, "daily_doc", array (), $condition); //
$allDocuments= showListDocuments::setAllDocuments($documents);
for($i=0;$i<count($allDocuments); $i++){
$obj1 = new ogbject1();
$obj1 ->setProperty(,$allDocuments[$i]['dbField']));
$allDocuments[$i]= $obj1;
}
}
function getAllDocuments(){
return $this->allDocuments;
}
public function setAllDocuments($val) {
$this->allDocuments = $val;
}Code: Select all
<?php
include_once("util/classes/showListDocuments.class.php");
$documents = new showListDocuments();
$documents->listDocuments();
$alldocuments = $documents->getAllDocuments();
?>
<body>
<?php
for($i=0; $i<count($alldocuments);$i++){
$obj1 = new object1();
$obj1= $alldocuments[$i];
echo $obj1->getProperty();
}
?>
</body>
Code: Select all
$obj1= $alldocuments[$i];can you help me?Fatal error: Call to a member function getProprieta() on a non-object in C:\xampp\htdocs\project\file.php on line 49
Thanks