本文整理汇总了PHP中Test::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Test::delete方法的具体用法?PHP Test::delete怎么用?PHP Test::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Test
的用法示例。
在下文中一共展示了Test::delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTable
function testTable()
{
$tb = Test::table();
$new_data = ['nickname' => 'z3'];
$tb->insert($new_data);
$this->assertEquals(1, $tb->count());
$this->assertEquals([['nickname' => 'z3']], $tb->selectData());
$update = $tb->update(['nickname' => 'w5']);
$this->assertEquals(1, $update);
$this->assertEquals([['nickname' => 'w5']], $tb->selectData());
$tb_new = clone $tb;
$tb_new->where('nickname=%s', 'w5');
//$this->assertEquals('SELEC', $tb->buildSelect());
$this->assertEquals([['nickname' => 'w5']], $tb_new->selectData());
$tb_new->clearWhere();
$tb_new->andWhere(['nickname' => 'w5']);
//$this->assertEquals('SELEC', $tb->buildSelect());
$this->assertEquals([['nickname' => 'w5']], $tb_new->selectData());
$this->assertEquals(1, $tb_new->update(['nickname' => 'z3']));
$this->assertEquals([['nickname' => 'z3']], $tb->selectData());
$obj_list = $tb->select();
$obj = $obj_list[0];
/* @var $obj Test */
$this->assertEquals('z3', $obj->nickname);
$tb->delete();
$test = new Test();
$test->nickname = 'hehe';
$this->assertEquals(TRUE, $test->save());
$this->assertEquals('hehe', Test::table()->selectData()[0]['nickname']);
$test->delete();
$this->assertEquals([], $tb->selectData());
$this->assertEquals('SELECT * FROM test Test', $tb->buildSelect());
$this->assertEquals('SELECT * FROM test Test LIMIT 10', $tb->buildSelect(10));
$this->assertEquals('SELECT * FROM test Test LIMIT 10 OFFSET 10', $tb->buildSelect(10, 10));
}
示例2: edit
public function edit($id = 0)
{
$obj = new User();
$obj->get_by_id((int) $id);
$testid = $this->session->userdata('testid');
$test = new Test();
$test->get_by_id($testid);
if (!$_POST) {
echo $obj->to_json();
} else {
if (isset($_POST['model']) and $model = $_POST['model']) {
$obj->from_json($model);
if ($obj->save()) {
$test->save($obj);
//保存关系
echo $obj->to_json();
} else {
echo json_encode(array('error' => $obj->error->string));
}
} else {
if (isset($_POST['_method']) and $_POST['_method'] === 'DELETE') {
$test->delete($obj);
$obj->delete();
}
}
}
}
示例3: json_encode
if (sizeof($response_data) == 0) {
$response[] = array('success' => 0, 'message' => 'No Data Found');
} else {
$response[] = array('success' => 1, 'data' => $response_data);
}
}
if ($tag == 'selectJoinTest') {
$table = "*";
$where = "col1=1";
$response_data = $test->select_join($table, $where);
if (sizeof($response_data) == 0) {
$response[] = array('success' => 0, 'message' => 'No Data Found');
} else {
$response[] = array('success' => 1, 'data' => $response_data);
}
}
if ($tag == 'deleteTest') {
$id = "12";
$response_data = $test->delete($id);
if (sizeof($response_data) == 0) {
$response[] = array('success' => 0, 'message' => 'Operation is not successful');
} else {
$response[] = array('success' => 1, 'message' => $test->table_name . ' Info Deleted');
}
}
} catch (Exception $ex) {
$response_data[0]['success'] = 1;
$response = array('posts' => $response_data);
}
$response = array('posts' => $response);
echo json_encode($response);
示例4: Test
<?php
include '../lib/common.inc.php';
$test = new Test();
$test->id = $_REQUEST['test_id'];
$test->delete();
示例5: delete_test
public function delete_test($test_id)
{
$output = new stdClass();
$output->result = FALSE;
$output->message = $this->lang->line('admin_tests_error_cant_find_test');
$this->_transaction_isolation();
$this->db->trans_begin();
$test = new Test();
$test->get_by_id(intval($test_id));
if ($test->exists()) {
$test->delete();
if ($this->db->trans_status()) {
$this->db->trans_commit();
$output->result = TRUE;
$output->message = $this->lang->line('admin_tests_delete_test_success');
} else {
$this->db->trans_rollback();
$output->message = $this->lang->line('admin_tests_error_cant_delete_test');
}
} else {
$this->db->trans_rollback();
}
$this->output->set_content_type('application/json');
$this->output->set_output(json_encode($output));
}