Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8920507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:17:15+00:00 2026-06-15T06:17:15+00:00

EDIT: Thats more invoking code: $worker = new Worker(); // :| $worker->addWorker($_POST); echo ‘Post

  • 0

EDIT: Thats more invoking code:

$worker = new Worker(); // :|
$worker->addWorker($_POST);
echo 'Post vars:<br>';
var_dump($_POST);
echo 'Object Worker parameters:<br>';
echo $worker->name;
get_object_vars(serialize($worker));
echo 'create<br>';
var_dump(serialize($worker));
$_SESSION['save_confirm'] = serialize($worker);

It looks like that:
var_dump shows correctly:

array(8) { [“name”]=> string(4) “Name” [“surname”]=> string(7) “Surname” [“dob”]=> string(10) “dd/mm/yyyy” [“skills”]=> string(3) “ERN” [“postcode”]=> string(8) “Postcode” [“street”]=> string(6) “Street” [“email”]=> string(5) “Email” [“action”]=> string(6) “create” }

while get_object_vars doesn’t work, echo $worker->name gives propper value.
, there’s PDO statement in this object, but ther’s also:

public function __sleep () { unset($conn); }

EDIT:
Classes:

class Worker extends Core {
    public $name;
    public $surname;
    public $dob;
    public $skills;
    public $postcode;
    public $street;
    public $email;
    public $tel;
    public $erefnumber;

    // Adding worker to object
    public function addWorker(  array $postArray)
    {
          $this->name = $postArray['name'];
          $this->surname = $postArray['surname'];
          $this->dob = $postArray['dob'];
          $this->skills = $postArray['skills'];
          $this->postcode = $postArray['postcode'];
          $this->street = $postArray['street'];
          $this->email = $postArray['email'];
          $this->tel = $postArray['tel'];
          $this->erefnumber = $postArray['erefnumber'];
    }

    //Saving worker data to database, need provide group name (table name)
    public function saveWorker($group) {
        if(isset($this->conn)) {
            try
            {
                parent::__construct();
                $this->conn ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //catch exceptions
                $q = query('INSERT INTO :group(name, surname, dob, skills, postcode, street, email, tel, erefnumber) VALUES(
                :name,
                :surname,
                :dob,
                :skills,
                :postcode,
                :street,
                :email,
                :tel,
                :erefnumber)'); //sql query with group name
                $query = $pdo->prepare($q);
                $stmt -> bindValue(':group', $group, PDO::PARAM_STR);
                $stmt -> bindValue(':name', $name, PDO::PARAM_STR);
                $stmt -> bindValue(':surname', $surname, PDO::PARAM_STR);
                $stmt -> bindValue(':dob', $dob, PDO::PARAM_STR);
                $stmt -> bindValue(':skills', $skills, PDO::PARAM_STR);
                $stmt -> bindValue(':postcode', $postcode, PDO::PARAM_STR);
                $stmt -> bindValue(':street', $street, PDO::PARAM_STR);
                $stmt -> bindValue(':email', $email, PDO::PARAM_STR);
                $stmt -> bindValue(':tel', $tel, PDO::PARAM_STR);
                $stmt -> bindValue(':erefnumber', $erefnumber, PDO::PARAM_STR);

                $results = $query->execute();
            }
            catch(PDOException $e) 
            {
              return 'There was some error: ' . $e->getMessage();
            }
        }

        else {
        echo 'no connection  (saveWorkers)';
        }

        unset($stmt);
        return var_dump($list);
        //no exceptions

    }

class Core {
    public $conn;
    public function __construct() {
        $this->dbConnect();
    }
    public function dbConnect() {

        $host = 'localhost';
        $port = '3307';
        $username = 'modium_test';
        $password = 'test';
        $database ='modium_test';   
        try{
                $this->conn = new PDO('mysql:host='.$host.';dbname='.$database.';port='.$port, $username, $password );
                echo 'Connection successful!';
                echo var_dump($this->conn);
        }
        catch(PDOException $e){
                echo 'Error: ' . $e->getMessage();
        }   
    }

    public function __sleep () {
        unset($conn);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:17:18+00:00Added an answer on June 15, 2026 at 6:17 am

    You are not passing object to get_object_vars, but a string.

    get_object_vars(serialize($worker));
    

    should be

    $object_vars = get_object_vars($worker);
    

    and now var_dump($object_vars); will show what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: I realized that this code compiles and works: #include <iostream> template<class Something> class
EDIT: For the inner queries, there could be more than one match per inner
I've got a DLL written in C (that I can't edit) that has some
Edit : Note that, as Daniel and latkin noted in an answer and a
I am trying to implement a control to edit text that will display the
Which algorithms or data structures are used in auto-suggest features? It seems that edit-distance
*edit: I understand that stackoverflow has banned all questions regarding using Microsoft's Visio. I'm
Edit : The bug that caused this problem has been fixed. The @version tag
I am making an activity that will edit the shared preferences just when the
Are there any editors that can edit multi-gigabyte text files, perhaps by only loading

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.