本文整理汇总了PHP中Survey::getQuestion方法的典型用法代码示例。如果您正苦于以下问题:PHP Survey::getQuestion方法的具体用法?PHP Survey::getQuestion怎么用?PHP Survey::getQuestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Survey
的用法示例。
在下文中一共展示了Survey::getQuestion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Database
* licence: GPLv3 <http://www.gnu.org/licenses/gpl-3.0.html>
*/
if (empty($_POST["question"]) && empty($_POST["answer"])) {
http_response_code(400);
}
/**
* Database object
*/
$database = new Database();
/**
* Question handler
*/
if (!empty($_POST["question"])) {
$questionId = $_POST["question"];
$survey = new Survey($database);
if ($question = $survey->getQuestion($questionId)) {
echo json_encode($question);
} else {
echo "Fout!";
}
}
/**
* Answer handler
*/
if (!empty($_POST["answer"])) {
$answer = $_POST["answer"];
$questionId = $_POST["questionId"];
$userId = $_POST["userId"];
$survey = new Survey($database);
if ($question = $survey->saveAnswer($userId, $questionId, $question)) {
echo "OK";
示例2: saveSurvey
/**
* Sauvegarde un sondage dans la base de donnée et met à jour les indentifiants
* du sondage et des réponses.
*
* @param Survey $survey Sondage à sauvegarder.
* @return boolean True si la sauvegarde a été réalisée avec succès, false sinon.
*/
public function saveSurvey($survey) {
/* TODO START */
$this->connection->beginTransaction();
$query = $this->connection->prepare("INSERT INTO surveys(owner,question)"."VALUES (?,?)");
if ($query===false){
$this->connection->rollback();
return false;
}
$r = $query->execute(array($survey->getOwner(), $survey->getQuestion()));
if ($r === false){
$this->connection->rollback();
return false;
}
$id = $this->connection->lastInsertId();
$survey->setId($id);
$responses = &$survey->getResponses();
foreach ($responses as &$response) {
if ($this->saveResponse($response)===false) {
$this->connection->rollback();
return false;
}
}
$this->connection->commit(); return true;
}
示例3:
$pdf->SetFont('freeserif', 'B', 12);
// set some text to print
$txt = <<<EOD
Софийски университет "Св. Климент Охридски"
EOD;
// print a block of text using Write()
$pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0);
// ---------------------------------------------------------
// set font
$pdf->SetFont('freeserif', '', 18);
$pdf->Ln(5);
$txt = "Резултати от анкета:";
$pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0);
// set font
$pdf->SetFont('freeserif', '', 16);
$txt = "\"" . $survey->getQuestion() . "\"";
$pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0);
$pdf->Ln(5);
// set cell padding
$pdf->setCellPaddings(1, 1, 1, 1);
// set cell margins
$pdf->setCellMargins(0, 0, 0, 0);
// set font
$pdf->SetFont('freeserif', 'B', 14);
$txt = 'Отговори';
$pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0);
// set color for background
$pdf->SetFillColor(225, 225, 225);
// set font
$pdf->SetFont('freeserif', '', 12);
// Multicell test