本文整理汇总了PHP中Crud::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Crud::insert方法的具体用法?PHP Crud::insert怎么用?PHP Crud::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crud
的用法示例。
在下文中一共展示了Crud::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: going
$show = '';
$i = 0;
while ($row = $this->result->fetchArray()) {
$show .= '<li><span class="number">' . $row[0] . '</span><span class="date">' . $row[1] . '</span></li>';
$i++;
}
echo '<ol start="0" id="history"><li class="close">X</li>', $show, '<li class="opacity"><span class="plus">-</span><span class="minus">+</span></li></ol>';
}
public function going($id)
{
$this->result = $this->query('SELECT ID, STATE, TIMESTAMP FROM HISTORY WHERE ID = ' . $id . ';');
echo $this->result->fetchArray()[1];
}
public function insert($ul)
{
$this->exec('INSERT INTO HISTORY (STATE) VALUES (\'' . SQLite3::escapeString($ul) . '\');');
$this->result = $this->query('SELECT ID, STATE, TIMESTAMP FROM HISTORY WHERE ID = (SELECT max(ID)FROM HISTORY);');
echo $this->result->fetchArray()[1];
}
}
$insertul = new Crud();
if (isset($_POST['history'])) {
$insertul->history();
}
if (isset($_POST['insert'])) {
$insertul->insert($_POST['insert']);
}
if (isset($_POST['id'])) {
$num = intval($_POST['id']);
$insertul->going($num);
}
示例2: update
echo "error:" . $sql . "<br>" . $conn->error;
}
}
public function update()
{
$sql = " Update faqs SET answer ='woh' WHERE id=1";
if ($this->conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
}
public function __destruct()
{
$this->conn->close();
}
}
$crud = new Crud();
switch ($_GET['action']) {
case "read":
$crud->read();
break;
case "update":
$crud->update();
break;
case "delete":
break;
case "insert":
$crud->insert();
break;
}