本文整理汇总了PHP中sql::save方法的典型用法代码示例。如果您正苦于以下问题:PHP sql::save方法的具体用法?PHP sql::save怎么用?PHP sql::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sql
的用法示例。
在下文中一共展示了sql::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isSaved
public static function isSaved($addon, $save = true)
{
$sql = new sql();
$num = $sql->num('SELECT 1 FROM ' . sql::table('addons') . ' WHERE `name` = "' . $addon . '"');
if (!$num && $save) {
$save = new sql();
$save->setTable('addons');
$save->addPost('name', $addon);
$save->save();
}
return $num;
}
示例2: sql
<?php
} else {
if (isset($_POST['sendNew'])) {
$new = new sql();
$new->setTable('user');
$admin = isset($_POST['admin']) ? 1 : 0;
$salt = userLogin::generateSalt();
$new->addPost('salt', $salt);
$new->addPost('firstname', type::post('firstname'));
$new->addPost('name', type::post('name'));
$new->addPost('email', type::post('email'));
$new->addPost('admin', $admin);
$new->addPost('username', type::post('username'));
$new->addPost('password', userLogin::hash(type::post('password'), $salt));
$new->save();
echo message::success(lang::get('user_added'));
}
if (isset($_POST['delete'])) {
$ids = type::post('ids');
if (is_array($ids) && count($ids) >= 1) {
if (in_array(rp::get('user')->get('id'), $ids)) {
echo message::danger(lang::get('user_delete_own'));
} else {
foreach ($ids as $var) {
$sql = new sql();
$sql->setTable('user');
$sql->setWhere("id=" . $var);
$sql->delete();
}
echo message::success(lang::get('user_deleted'));
示例3: newInstall
public static function newInstall()
{
$sql = new sql();
$sql->query('DROP TABLE `' . sql::table('module') . '`');
$sql->query('CREATE TABLE `' . sql::table("module") . '` (
`id` int(16) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`input` text NOT NULL,
`output` text NOT NULL,
`sort` int(16) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;');
$sql->query('DROP TABLE `' . sql::table('structure') . '`');
$sql->query('CREATE TABLE `' . sql::table("structure") . '` (
`id` int(16) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`template` varchar(255) NOT NULL,
`sort` int(16) unsigned NOT NULL,
`parent_id` int(16) unsigned NOT NULL,
`online` int(1) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;');
$sql->query('DROP TABLE `' . sql::table('user') . '`');
$sql->query('CREATE TABLE `' . sql::table("user") . '` (
`id` int(11) unsigned NOT NULL auto_increment,
`firstname` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`perms` varchar(255) NOT NULL,
`admin` int(1) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;');
$sql->setTable('user');
$sql->addPost('firstname', type::post('firstname'));
$sql->addPost('name', type::post('name'));
$sql->addPost('email', type::post('email'));
$sql->addPost('password', userLogin::hash(type::post('password')));
$sql->addPost('admin', 1);
$sql->save();
$sql->query('DROP TABLE `' . sql::table('structure_area') . '`');
$sql->query('CREATE TABLE `' . sql::table("structure_area") . '` (
`id` int(16) unsigned NOT NULL auto_increment,
`structure_id`int(16) unsigned NOT NULL,
`sort` int(16) unsigned NOT NULL,
`modul` int(16) unsigned NOT NULL,
`online` int(1) unsigned NOT NULL,
`value1` text NOT NULL,
`value2` text NOT NULL,
`value3` text NOT NULL,
`value4` text NOT NULL,
`value5` text NOT NULL,
`value6` text NOT NULL,
`value7` text NOT NULL,
`value8` text NOT NULL,
`value9` text NOT NULL,
`value10` text NOT NULL,
`value11` text NOT NULL,
`value12` text NOT NULL,
`value13` text NOT NULL,
`value14` text NOT NULL,
`value15` text NOT NULL,
`link1` int(11) NOT NULL,
`link2` int(11) NOT NULL,
`link3` int(11) NOT NULL,
`link4` int(11) NOT NULL,
`link5` int(11) NOT NULL,
`link6` int(11) NOT NULL,
`link7` int(11) NOT NULL,
`link8` int(11) NOT NULL,
`link9` int(11) NOT NULL,
`link10` int(11) NOT NULL,
`linklist1` varchar(255) NOT NULL,
`linklist2` varchar(255) NOT NULL,
`linklist3` varchar(255) NOT NULL,
`linklist4` varchar(255) NOT NULL,
`linklist5` varchar(255) NOT NULL,
`linklist6` varchar(255) NOT NULL,
`linklist7` varchar(255) NOT NULL,
`linklist8` varchar(255) NOT NULL,
`linklist9` varchar(255) NOT NULL,
`linklist10` varchar(255) NOT NULL,
`php1` text NOT NULL,
`php2` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;');
$sql->query('DROP TABLE `' . sql::table('addons') . '`');
$sql->query('CREATE TABLE `' . sql::table("addons") . '` (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`active` int(1) NOT NULL,
`install` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;');
$sql->query('DROP TABLE `' . sql::table('slots') . '`');
$sql->query('CREATE TABLE `' . sql::table("slots") . '` (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`template` varchar(255) NOT NULL,
//.........这里部分代码省略.........
示例4: unset
<?php
if (isset($_POST['check'])) {
$DB = rp::get('DB');
sql::connect($DB['host'], $DB['user'], $DB['password'], $DB['database']);
unset($DB);
$sql = new sql();
$salt = userLogin::generateSalt();
$sql->setTable('user');
$sql->addPost('firstname', type::post('firstname'));
$sql->addPost('name', type::post('name'));
$sql->addPost('username', type::post('username'));
$sql->addPost('email', type::post('email'));
$sql->addPost('password', userLogin::hash(type::post('password'), $salt));
$sql->addPost('salt', $salt);
$sql->addPost('admin', 1);
$sql->save();
rp::add('setup', false, true);
rp::save();
header('Location: ?page=finish');
exit;
}
?>
<div class="input row">
<label class="col-sm-4"><?php
echo lang::get('firstname');
?>
</label>
<div class="col-sm-8">
<input type="text" name="firstname" value="<?php
echo type::post('firstname');
示例5: header
$auth = $_POST['auth'];
$authKey = "";
if ($auth != $authKey) {
header("HTTP/1.1 403 Forbidden");
die(json_encode(array('code' => 'error', 'comment' => 'auth failed with authkey: ' . $auth)));
}
$db = new sql('host', 'db', 'table', 'user', 'password');
switch ($function) {
case 'listall':
echo $db->listall();
break;
case 'save':
if ($db->exists($itemName)) {
echo $db->update($itemName, $itemCount);
} else {
echo $db->save($itemName, $itemCount);
}
break;
case 'update':
echo $db->update($itemName, $itemCount);
break;
case 'delete':
echo $db->delete($itemName);
break;
case 'clear':
echo $db->clear();
break;
default:
die(json_encode(array('code' => 'error', 'comment' => 'function not specified')));
}
?>