本文整理汇总了PHP中site::create方法的典型用法代码示例。如果您正苦于以下问题:PHP site::create方法的具体用法?PHP site::create怎么用?PHP site::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类site
的用法示例。
在下文中一共展示了site::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: created
function created()
{
$site = new site();
$site->name = $_POST['name'];
$site->bonus_type = $_POST['bonus_type'];
$site->bonus_max = $_POST['bonus_max'];
$site->convert_rate = $_POST['convert_rate'];
$site->affiliate_url = "";
$site->url = "";
$site->comment = $_POST['comment'];
$site->create();
header("location: index.php");
}
示例2: catch
$stmt->execute();
$row = $stmt->fetchall(PDO::FETCH_CLASS, 'site');
return $row;
} catch (PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
}
function create()
{
try {
$conn = new PDO(PDOCONNECT, PDOUSERNAME, PDOPASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare('INSERT INTO sites SET name=:name,comment=:comment');
$stmt->execute(array("name" => $this->name, "comment" => $this->comment));
return $conn->lastInsertId();
} catch (PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
}
}
if (isset($_GET['c']) && $_GET['c'] == "create") {
$site = new site();
$site->name = $_POST['name'];
$site->comment = $_POST['comment'];
$id = $site->create();
return $id;
} elseif (isset($_GET['c']) && $_GET['c'] == "all") {
$sites = site::all();
echo json_encode($sites);
exit;
}