當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sql::save方法代碼示例

本文整理匯總了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;
 }
開發者ID:DINKIN,項目名稱:rokket,代碼行數:12,代碼來源:config.php

示例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'));
開發者ID:DINKIN,項目名稱:rokket,代碼行數:30,代碼來源:user.php

示例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,
//.........這裏部分代碼省略.........
開發者ID:pasternt,項目名稱:dynaoCMS,代碼行數:101,代碼來源:install.php

示例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');
開發者ID:DINKIN,項目名稱:rokket,代碼行數:31,代碼來源:user.php

示例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')));
}
?>
開發者ID:vaginessa,項目名稱:ShoppingList_backend,代碼行數:31,代碼來源:api.php


注:本文中的sql::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。