我介紹給爾康,一個PHP框架,按照教程:https://docs.phalconphp.com/en/latest/reference/tutorial-rest.htmlPHP,框架 - 類必須聲明爲抽象
我面臨這個問題:我在下面
代碼有此錯誤類機器人必須聲明爲抽象或實現方法 'getConnectionService(),setForceExists()等。'
<?php
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Message;
use Phalcon\Mvc\Model\Validator\Uniqueness;
use Phalcon\Mvc\Model\Validator\InclusionIn;
class Robots extends Model{
public function validation()
{
// Type must be: droid, mechanical or virtual
$this->validate(
new InclusionIn(
array(
"field" => "type",
"domain" => array(
"droid",
"mechanical",
"virtual"
)
)
)
);
// Robot name must be unique
$this->validate(
new Uniqueness(
array(
"field" => "name",
"message" => "The robot name must be unique"
)
)
);
// Year cannot be less than zero
if ($this->year < 0) {
$this->appendMessage(new Message("The year cannot be less than zero"));
}
// Check if any messages have been produced
if ($this->validationHasFailed() == true) {
return false;
}
}
}
?>
即使我試圖執行一個HTTP請求,我得到:
無法實例抽象類機器人
任何想法?
添加:使用Phalcon \ Mvc \ Model;在宣佈課程之前。 – Cerad
是的,對不起,我省略了那部分。上傳了它,但問題仍然存在。 – cventr
您是否從下一教程步驟定義了您的數據庫連接服務? – yergo