Nesne dizeye dönüştürülür olamazdı?

0 Cevap

Neden bu hatayı alıyorum:

Catchable fatal error: Object of class Card could not be converted to string in /f5/debate/public/Card.php on line 79

İşte kod:

public function insert() {
            $mysql = new DB(debate);

            $this->initializeInsert();

            $query = "INSERT INTO cards VALUES('$this->$type','$this->$tag','$this->$author->$last','$this->$author->$first','$this->$author->$qualifications','$this->$date->$year','$this->$date->$month','$this->$date->$day','$this->$title', '$this->$source', '$this->$text')";
            $mysql->execute($query);
        }

(Hat 79 $ sorgu ve fonksiyon sınıf "Kart" parçası)

"Kart" tüm beyanlar:

    public $type;

    public $tag;
    public $title;
    public $source;
    public $text;

    public function __construct() {
        $this->date = new Date;
        $this->author = new Author;
    }

Bu hat 79 değiştirdikten sonra:

$query = "INSERT INTO cards VALUES('$this->type','$this->tag','$this->author->last','$this->author->first','$this-$author->qualifications','$this->date->year','$this->date->month','$this->date->day','$this->title', '$this->source', '$this->text')";

Ben şimdi bu hatayı alıyorum:

Catchable fatal error: Object of class Author could not be converted to string in /f5/debate/public/Card.php on line 79

0 Cevap