本文整理汇总了PHP中Answer::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Answer::delete方法的具体用法?PHP Answer::delete怎么用?PHP Answer::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Answer
的用法示例。
在下文中一共展示了Answer::delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit($step)
{
$obj = new Answer();
if (!$_POST) {
$data = $this->_get_test();
$topics = $data['topics'];
$topic_id = $topics[$step - 1]['id'];
$condition = array('user_id' => $this->_user->id, 'topic_id' => $topic_id);
$obj->where($condition)->get();
$json = array_merge($obj->to_array(), $this->_get_test());
$json['aChoose'] = $json['aChoose'] ? explode(',', $json['aChoose']) : array();
echo json_encode($this->_filter($json));
} else {
if (isset($_POST['model']) and $model = $_POST['model']) {
$data = json_decode($model);
$get = $this->_save($data);
if (isset($get['error'])) {
json_encode($get);
} else {
$get['aChoose'] = explode(',', $get['aChoose']);
echo json_encode($this->_filter($get));
}
} else {
if (isset($_POST['_method']) and $_POST['_method'] === 'DELETE') {
$obj->delete();
}
}
}
}
示例2: delete
public static function delete($id)
{
$db = Connection::getInstance();
// delete answer
require_once ROOT . DS . 'application' . DS . 'model' . DS . 'class.answer.php';
Answer::delete($id);
// delete thread
$sql = "DELETE FROM sse_thread WHERE thread_id = :id";
$statement = $db->prepare($sql);
$statement->execute(array(':id' => $id));
}
示例3: connectToEncryptedMySQL
<?php
require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
require_once "answer.php";
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/jfindley2.ini");
$answer = new Answer(null, 1, 2, "The answer", null);
$answer->insert($pdo);
$answer->setAnswerText("A better answer");
$answer->update($pdo);
$answer->delete($pdo);
示例4: Answer
function test_delete()
{
//Arrange
$test_field = "Joe FindById";
$test_quest_id = 1;
$test_answer = new Answer($test_field, $test_quest_id);
$test_answer->save();
$test_field2 = "Red FindById";
$test_quest_id2 = 2;
$test_answer2 = new Answer($test_field2, $test_quest_id2);
$test_answer2->save();
//Act
$test_answer->delete();
$result = Answer::getAll();
//Assert
$this->assertEquals($test_answer2, $result[0]);
}