本文整理汇总了PHP中connection::create方法的典型用法代码示例。如果您正苦于以下问题:PHP connection::create方法的具体用法?PHP connection::create怎么用?PHP connection::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connection
的用法示例。
在下文中一共展示了connection::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateUser
public function testCreateUser()
{
$params = array('table' => 'my_record', 'first_name' => 'fname', 'last_name' => 'lname', 'address' => 'address', 'phone' => 'phone');
$conn = new connection();
$result = $conn->create('users', 'fname', 'lname', 'address', 'phone');
$this->assertEquals(true, $result);
}
示例2: NOW
///////////////////////create trigger to products////////////***************
$query = "DELIMITER //\n\t\t\tCREATE TRIGGER changes BEFORE INSERT ON\n\t\t\tProducts FOR EACH ROW BEGIN\n\t\t\t\t\tUPDATE changes\n\t\t\tSET changeDate = NOW() where tableName='Products'\n\t\t\tEND //\n\t\t\tDELIMITER ;";
mysqli_query(connection::$obj, $query);
///////////////////////create trigger to category////////////***************
$query = "DELIMITER //\n\t\t\tCREATE TRIGGER changes BEFORE INSERT ON\n\t\t\tCategory FOR EACH ROW BEGIN\n\t\t\t\t\t\tUPDATE changes\n\t\t\tSET changeDate = NOW() where tableName='Category'\n\t\t\tEND //\n\t\t\tDELIMITER ;";
mysqli_query(connection::$obj, $query);
///////////////////////create trigger to Room////////////***************
$query = "DELIMITER //\n\t\t\tCREATE TRIGGER changes BEFORE INSERT ON\n\t\t\tRoom FOR EACH ROW BEGIN\n\t\t\t\t\t\tUPDATE changes\n\t\t\tSET changeDate = NOW() where tableName='Room'\n\t\t\tEND //\n\t\t\tDELIMITER ;";
mysqli_query(connection::$obj, $query);
//////////////////////create trigger to Orders////////////***************
$query = "DELIMITER //\n\t\t\tCREATE TRIGGER changes BEFORE INSERT ON\n\t\t\tOrders FOR EACH ROW BEGIN\n\t\t\t\t\t\tUPDATE changes\n\t\t\tSET changeDate = NOW() where tableName='Orders'\n\t\t\tEND //\n\t\t\tDELIMITER ;";
mysqli_query(connection::$obj, $query);
/////////////////add relationship between tables
$sq = "alter table Users add foreign key (rid) references Room (rid);";
connection::$obj->query($sq);
$sq = "alter table Products add foreign key (cid) references Category (cid);";
connection::$obj->query($sq);
$sq = "alter table Orders add foreign key (uid) references Users (uid);";
connection::$obj->query($sq);
$sq = "alter table Orders add foreign key (rid) references Room (rid);";
connection::$obj->query($sq);
$sq = "alter table orderProducts add foreign key (oid) references Orders (oid);";
connection::$obj->query($sq);
$sq = "alter table orderProducts add foreign key (pid) references Products (pid);";
connection::$obj->query($sq);
$sq = "alter table orderProducts add primary key (oid,pid);";
connection::$obj->query($sq);
}
}
connection::create();
示例3: connection
<?php
include_once 'connection.php';
$con = new connection();
$table = "users";
if (isset($_POST['submit'])) {
$fname = $_POST['first_name'];
$lname = $_POST['last_name'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$res = $con->create($table, $fname, $lname, $address, $phone);
if ($res) {
header('Location: ' . 'index.php');
}
}
?>
<html>
<head>
<title>CRUD</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">
<label for="Edit user">Create User:</label>
<form method="post">
<table align="center" class="table table-bordered">
<tr>
<td>First Name:</td>
<td><input type="text" name="first_name" placeholder="First Name" required/></td>