本文整理汇总了PHP中sql::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP sql::exists方法的具体用法?PHP sql::exists怎么用?PHP sql::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sql
的用法示例。
在下文中一共展示了sql::exists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: int
<?php
/************************************************************************
* Dashboard2
* Copyright 2006-2010 by Niels Leenheer
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
if (!sql::exists("media")) {
sql::create("media", "\r\n\t\t\t`ID` int(11) NOT NULL auto_increment,\r\n\t\t\t`folder` int(11) NOT NULL default '0',\r\n\t\t\t`filename` varchar(255) NOT NULL default '',\r\n\t\t\t`original` varchar(255) NOT NULL default '',\r\n\t\t\t`width` int(11) NOT NULL default '0',\r\n\t\t\t`height` int(11) NOT NULL default '0',\r\n\t\t\t`size` int(11) NOT NULL default '0',\r\n\t\t\t`modified` datetime NOT NULL default '0000-00-00 00:00:00',\r\n\t\t\t`deleted` int(4) NOT NULL default '0',\r\n\t\t\tPRIMARY KEY (`ID`)\r\n\t\t");
sql::create("media_folder", "\r\n\t\t\t`ID` int(11) NOT NULL auto_increment,\r\n\t\t\t`order` int(11) NOT NULL default '0',\r\n\t\t\t`name` varchar(50) NOT NULL default '',\r\n\t\t\tPRIMARY KEY (`ID`)\r\n\t\t");
/* Create or first folder */
sql::query("INSERT INTO " . _TABLE_PREFIX_ . "media_folder SET `ID`=1, `order`=0, `name`='Standard'");
}
sql::query("INSERT INTO " . _TABLE_PREFIX_ . "strings SET language='nl', id='image', value='Afbeelding'");
sql::query("INSERT INTO " . _TABLE_PREFIX_ . "strings SET language='nl', id='selectimage', value='Selecteer afbeelding'");
sql::query("INSERT INTO " . _TABLE_PREFIX_ . "strings SET language='nl', id='imagesonwebsite', value='Afbeeldingen op uw website'");
sql::query("INSERT INTO " . _TABLE_PREFIX_ . "strings SET language='en', id='image', value='Image'");
sql::query("INSERT INTO " . _TABLE_PREFIX_ . "strings SET language='en', id='selectimage', value='Select image'");
sql::query("INSERT INTO " . _TABLE_PREFIX_ . "strings SET language='nl', id='imagesonwebsite', value='Images on your website'");
示例2: varchar
sql::create("plugins_event", "\r\n\t\t`name` varchar(254) NOT NULL default '',\r\n\t\t`plugin` varchar(254) NOT NULL default '',\r\n\t\tPRIMARY KEY (`name`(128),`plugin`(128))\r\n\t");
sql::create("plugins_types", "\r\n\t\t`ID` varchar(254) NOT NULL default '',\r\n\t\t`plugin` varchar(254) NOT NULL default '',\r\n\t\t`children_allowed` text NOT NULL default '',\r\n\t\t`parents_allowed` text NOT NULL default '',\r\n\t\t`root_allowed` int(11) NOT NULL default '1',\r\n\t\t`visible` int(11) NOT NULL default '1',\r\n\t\tPRIMARY KEY (`ID`)\r\n\t");
if (!sql::exists("types")) {
sql::create("types", "\r\n\t\t\t`ID` int(11) NOT NULL auto_increment,\r\n\t\t\t`name` varchar(254) NOT NULL default '',\r\n\t\t\t`children_allowed` text NOT NULL default '',\r\n\t\t\t`parents_allowed` text NOT NULL default '',\r\n\t\t\t`root_allowed` int(11) NOT NULL default '1',\r\n\t\t\t`visible` int(11) NOT NULL default '1',\r\n\t\t\t`sort` int(11) NOT NULL default '0',\r\n\t\t\tPRIMARY KEY (`ID`)\r\n\t\t");
sql::create("types_groups", "\r\n\t\t\t`type` int(11) NOT NULL default '0',\r\n\t\t\t`group` int(11) NOT NULL default '0',\r\n\t\t\t`content` text NOT NULL,\r\n\t\t\tPRIMARY KEY (`type`,`group`)\r\n\t\t");
/* Create the default pagetype */
sql::query("\r\n\t\t\tINSERT INTO " . _TABLE_PREFIX_ . "types SET \r\n\t\t\t\t`ID`=1, `name`='Default', `children_allowed`= '*', `parents_allowed`= '*', `root_allowed`= 1\r\n\t\t");
sql::query("\r\n\t\t\tINSERT INTO " . _TABLE_PREFIX_ . "types_groups SET \r\n\t\t\t\t`type`=1, `group`=0, `content`= 'title,story'\r\n\t\t");
}
/* Basic tables */
sql::create("config", "\r\n\t\t`name` varchar(254) NOT NULL default '',\r\n\t\t`type` varchar(254) NOT NULL default '',\r\n\t\t`data` text NOT NULL,\r\n\t\tPRIMARY KEY (`name`)\r\n\t");
sql::create("tickets", "\r\n\t\t`ticket` varchar(64) NOT NULL default '',\r\n\t\t`id` int(64) NOT NULL default '0',\r\n\t\t`generated` datetime NOT NULL default '0000-00-00 00:00:00'\r\n\t");
/* Translation and languages */
if (!sql::exists("language")) {
sql::create("language", "\r\n\t\t\t`id` char(2) NOT NULL default '',\r\n\t\t\t`name` varchar(50) NOT NULL default '',\r\n\t\t\t`public` int(4) NOT NULL default '0',\r\n\t\t\t`position` int(11) NOT NULL default '0',\r\n\t\t\t`site` int(11) NOT NULL default '0',\r\n\t\t\tUNIQUE KEY `id_site` (`id`,`site`)\r\n\t\t");
/* Create our default language */
sql::query("INSERT INTO " . _TABLE_PREFIX_ . "language SET `id`='" . _DEFAULT_LANGUAGE_ . "', `name`='" . _DEFAULT_LANGUAGE_NAME_ . "', `public`=1, `site`=" . _DEFAULT_SITE_);
}
sql::create("strings", "\r\n\t\t`id` varchar(255) NOT NULL default '',\r\n\t\t`language` varchar(5) NOT NULL default '',\r\n\t\t`value` text NOT NULL,\r\n\t\t`group` varchar(64) NOT NULL default '',\r\n\t\tUNIQUE KEY `id_language` (`id`,`language`)\r\n\t");
sql::create("strings_groups", "\r\n\t\t`group` varchar(64) NOT NULL default '',\r\n\t\t`name` varchar(255) NOT NULL default '',\r\n\t\tPRIMARY KEY (`group`)\r\n\t");
/* Content */
if (!sql::exists("contents")) {
sql::create("contents", "\r\n\t\t\t`ID` int(11) NOT NULL auto_increment,\r\n\t\t\t`parent` int(11) NOT NULL default '0',\r\n\t\t\t`left` int(11) NOT NULL default '0',\r\n\t\t\t`right` int(11) NOT NULL default '0',\r\n\t\t\t`site` int(11) NOT NULL default '0',\r\n\t\t\t`name` varchar(254) NOT NULL default '',\r\n\t\t\t`title` varchar(254) NOT NULL default '',\r\n\t\t\t`slug` varchar(254) NOT NULL default '',\r\n\t\t\t`type` varchar(64) NOT NULL default '',\r\n\t\t\t`revision` int(11) NOT NULL default '0',\r\n\t\t\t`status` int(11) NOT NULL default '0',\r\n\t\t\t`set` int(11) NOT NULL default '0',\r\n\t\t\t`position` int(11) default NULL,\r\n\t\t\t`r_view` int(11) NOT NULL default '0',\r\n\t\t\t`r_view_inv` int(11) NOT NULL default '0',\r\n\t\t\t`r_edit` int(11) NOT NULL default '0',\r\n\t\t\t`r_edit_inv` int(11) NOT NULL default '0',\r\n\t\t\t`r_create` int(11) NOT NULL default '0',\r\n\t\t\t`r_create_inv` int(11) NOT NULL default '0',\r\n\t\t\t`r_admin` int(11) NOT NULL default '0',\r\n\t\t\t`r_admin_inv` int(11) NOT NULL default '0',\r\n\t\t\t`author` int(11) NOT NULL default '0',\r\n\t\t\t`language` char(2) NOT NULL default 'nl',\r\n\t\t\t`activation` int(11) NOT NULL default '0',\r\n\t\t\t`expiration` int(11) NOT NULL default '0',\r\n\t\t\t`created` int(11) NOT NULL default '0',\r\n\t\t\t`published` int(11) NOT NULL default '0',\r\n\t\t\t`modified` int(11) NOT NULL default '0',\r\n\t\t\t`visible` int(11) NOT NULL default '1',\r\n\t\t\tPRIMARY KEY (`ID`)\r\n\t\t");
/* Create the default homepage */
sql::query("\r\n\t\t\tINSERT INTO " . _TABLE_PREFIX_ . "contents SET \r\n\t\t\t\t`ID`=1, `parent`=0, `left`=1, `right`=2, `site`=" . _DEFAULT_SITE_ . ", `name`='Home', `title`='', `slug`='index', `type`='1', `revision`=0, \r\n\t\t\t\t`status`=1, `set`=0, `position`=0, `r_view`=3, `r_view_inv`=0, `r_edit`=6, `r_edit_inv`=0, `r_create`=6, `r_create_inv`=0,\r\n\t\t\t\t`r_admin`=6, `r_admin_inv`=0, `author`=1, `language`='" . _DEFAULT_LANGUAGE_ . "', \r\n\t\t\t\t`activation`=0, `expiration`=0, `created`= " . time() . ", `published` = " . time() . ", `modified`= " . time() . ", \r\n\t\t\t\t`visible`=1\r\n\t\t");
}
if (!sql::exists("contents_revisions")) {
sql::create("contents_revisions", "\r\n\t\t\t`ID` int(11) NOT NULL default '0',\r\n\t\t\t`revision` int(11) NOT NULL default '0',\r\n\t\t\t`created` int(11) NOT NULL default '0',\r\n\t\t\t`modified` int(11) NOT NULL default '0',\r\n\t\t\t`description` text NOT NULL,\r\n\t\t\t`author` int(11) NOT NULL default '0',\r\n\t\t\tUNIQUE KEY `id_revision` (`ID`,`revision`)\r\n\t\t");
/* Create the default homepage */
sql::query("\r\n\t\t\tINSERT INTO " . _TABLE_PREFIX_ . "contents_revisions SET \r\n\t\t\t\t`ID`=1, `revision`=0, `created`= " . time() . ", `modified`= " . time() . ", `author`=1\r\n\t\t");
}
示例3: create
function create($name, $definition)
{
if (!sql::exists($name)) {
sql::query("CREATE TABLE `" . _TABLE_PREFIX_ . $name . "` (" . $definition . ")");
}
}
示例4: header
$itemName = $_POST['item'];
$itemCount = $_POST['count'];
$function = $_POST['function'];
$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: