creating new instance fails PHP

Posted by as3isolib on Stack Overflow See other posts from Stack Overflow or by as3isolib
Published on 2012-11-12T22:56:41Z Indexed on 2012/11/12 23:00 UTC
Read the original article Hit count: 190

Filed under:
|
|
|
|

I am relatively new to PHP and having some decent success however I am running into this issue:

If I try to create a new instance of the class GenericEntryVO, I get a 500 error with little to no helpful error information. However, if I use a generic object as the result, I get no errors. I'd like to be able to cast this object as a GenericEntryVO as I am using AMFPHP to communicate serialize data with a Flex client.

I've read a few different ways to create constructors in PHP but the typical 'public function Foo()' for a class Foo was recommended for PHP 5.4.4

//in my EntryService.php class
public function getEntryByID($id)
{
    $link = mysqli_connect("localhost", "root", "root", "BabyTrackingAppDB");

    if (mysqli_connect_errno())
    {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }

    $query = "SELECT * FROM Entries WHERE id = '$id' LIMIT 1";

    if ($result = mysqli_query($link, $query))
    {
        // $entry = new GenericEntryVO(); this is where the problem lies!

        while ($row = mysqli_fetch_row($result))
        {
            $entry->id = $row[0];
            $entry->entryType = $row[1];
            $entry->title = $row[2];
            $entry->description = $row[3];
            $entry->value = $row[4];
            $entry->created = $row[5];
            $entry->updated = $row[6];
        }
    }

    mysqli_free_result($result);
    mysqli_close($link);

    return $entry;
}

//my GenericEntryVO.php class 
<?php

class GenericEntryVO
{
    public function __construct()
    {
    }

    public $id; 
    public $title;
    public $entryType;
    public $description;
    public $value;


    public $created;
    public $updated;

    // public $properties;
}

?>

© Stack Overflow or respective owner

Related posts about php

Related posts about oop