Создание викторины на Vue.js
5 min
Tutorial
Translation
Я не понимаю Angular. Мне очень нравится React, но я все еще изучаю его основы. Давайте попробуем Vue. Я расскажу, как я сделал микро-викторину.
Web-разработчик
Я не понимаю Angular. Мне очень нравится React, но я все еще изучаю его основы. Давайте попробуем Vue. Я расскажу, как я сделал микро-викторину.
class Foo
{
protected $db;
public $id;
public $bar;
public function __construct(PDO $db)
{
$this->db = $db;
}
public function do_something()
{
$this->bar .= uniqid();
}
public function save()
{
if ($this->id) {
$sql = "UPDATE foo SET bar = :bar WHERE id = :id";
$statement = $this->db->prepare($sql);
$statement->bindParam("bar", $this->bar);
$statement->bindParam("id", $this->id);
$statement->execute();
}
else {
$sql = "INSERT INTO foo (bar) VALUES (:bar)";
$statement = $this->db->prepare($sql);
$statement->bindParam("bar", $this->bar);
$statement->execute();
$this->id = $this->db->lastInsertId();
}
}
}
//Insert
$foo = new Foo($db);
$foo->bar = 'baz';
$foo->save();