(Joke) Object Entity not being created properly

Hello.

I’m adapting the framework created in the PHP Novice to Ninja (6th Ed) to create a bigger website including blog, calendar, and some degree of user CMS).

I’ve reached the point in the book where Joke Categories are added, and everything is becoming OOP (pg 577 Relationships-AssignCategory)

I had some problems getting it to work and did the following to attempt to elucidate my problems:

Blockquote

        public function saveEdit() {
        $author = $this->authentication->getUser();

        $blog = $_POST['blog'];
        //the above is from form, below is others
        $blog['blogDate'] = new \DateTime();

        $blogEntity = $author->addBlog($blog);

        foreach ($_POST['category'] as $categoryId) {
            $blogEntity->addCategory($categoryId);
        }

        echo '<pre>'; print_r($blogEntity); echo '</pre>'; 

Which printed the following:

Blockquote

   Site\Entity\Blog Object
 (
[id] => 151
[authorId] => 6
[blogdate] => 
[blogtext] => 
[authorsTable:Site\Entity\Blog:private] => Ninja\DatabaseTable Object
    (
        [pdo:Ninja\DatabaseTable:private] => PDO Object
            (
            )

        [table:Ninja\DatabaseTable:private] => author
        [primaryKey:Ninja\DatabaseTable:private] => id
        [className:Ninja\DatabaseTable:private] => \Site\Entity\Author
        [constructorArgs:Ninja\DatabaseTable:private] => Array
            (
                [0] => Ninja\DatabaseTable Object
                    (
                        [pdo:Ninja\DatabaseTable:private] => PDO Object
                            (
                            )

                        [table:Ninja\DatabaseTable:private] => blog
                        [primaryKey:Ninja\DatabaseTable:private] => id
                        [className:Ninja\DatabaseTable:private] => \Site\Entity\Blog
                        [constructorArgs:Ninja\DatabaseTable:private] => Array
                            (
                                [0] => Ninja\DatabaseTable Object
  *RECURSION* 
   //...

Having done the same on the code from the book, I can see that [blogdate] and [blogtext] shouldn’t be empty, but I am not getting any error messages to help me elucidate what is breaking.

The blog categories and the blog itself are getting inserted though

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.