本文整理汇总了PHP中database::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP database::insert方法的具体用法?PHP database::insert怎么用?PHP database::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database
的用法示例。
在下文中一共展示了database::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_list
public static function update_list()
{
database::delete("permission");
foreach (self::list_of_existing_permissions() as $perm => $descr) {
database::insert("permission", array("permission" => $perm, "description" => $descr));
}
}
示例2: set
public static function set($variable, $value)
{
$v = json_encode($value);
if (!self::exists($variable)) {
database::insert("variables", array("variable_name" => $variable, "variable_value" => $v));
} else {
database::update("variables", array("variable_value" => $v), "variable_name='%var'", array("%var" => $variable));
}
}
示例3: insert
function insert()
{
$this->onInsert();
if (!$this->validate($errors)) {
return false;
}
$db = new database();
$db->drop($this);
$db->table = $this->__table;
return $db->insert();
}
示例4: register_command
public static function register_command($nick, $ircdata = array())
{
$chan = core::get_chan(&$ircdata, 0);
$desc = core::get_data_after(&$ircdata, 1);
// get the channel.
if ($user = services::user_exists($nick, true, array('display', 'id'))) {
if (trim($desc) == '' || $chan == '' || $chan[0] != '#' || stristr($channel, ' ')) {
services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'INFO'));
// wrong syntax
return false;
}
if (services::chan_exists($chan, array('channel')) !== false) {
services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_REGISTERED_CHAN, array('chan' => $chan));
return false;
}
// check if its registered?
if (!strstr(core::$chans[$chan]['users'][$nick], 'o')) {
services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_NEED_CHAN_OP, array('chan' => $chan));
return false;
}
// we need to check if the user trying to register it has +o
// if not we tell them to GET IT!
$chan_info = array('channel' => $chan, 'timestamp' => core::$network_time, 'last_timestamp' => core::$network_time, 'topic' => core::$chans[$chan]['topic'], 'topic_setter' => core::$chans[$chan]['topic_setter']);
$rflags = core::$config->chanserv->default_flags;
$rflags = str_replace('d', '', $rflags);
$rflags = str_replace('u', '', $rflags);
$rflags = str_replace('e', '', $rflags);
$rflags = str_replace('w', '', $rflags);
$rflags = str_replace('m', '', $rflags);
$rflags = str_replace('t', '', $rflags);
// ignore parameter flags
database::insert('chans', $chan_info);
database::insert('chans_levels', array('channel' => $chan, 'target' => $user->display, 'flags' => 'Ftfrsqao'));
database::insert('chans_flags', array('channel' => $chan, 'flags' => $rflags . 'd', 'desc' => $desc));
// create the channel! WOOOH
services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_CHAN_REGISTERED, array('chan' => $chan));
core::alog(core::$config->chanserv->nick . ': ' . $chan . ' registered by ' . core::get_full_hostname($nick));
// logchan
core::alog('register_command(): ' . $chan . ' registered by ' . core::get_full_hostname($nick), 'BASIC');
// log what we need to log.
if ($channel = services::chan_exists($chan, array('channel', 'topic', 'suspended'))) {
chanserv::_join_channel(&$channel);
// join the channel
}
// does the channel exist?
} else {
services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_UNREGISTERED);
return false;
// ph00s aint even registered..
}
}
示例5: suspend_command
public static function suspend_command($nick, $ircdata = array())
{
$chan = core::get_chan(&$ircdata, 0);
$reason = core::get_data_after(&$ircdata, 1);
$chan_info = array();
// get the channel.
if (!core::$nicks[$nick]['ircop'] || services::user_exists($nick, true, array('display', 'identified')) === false) {
services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
return false;
}
// they've gotta be identified and opered..
if ($chan == '' || $chan[0] != '#') {
services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'SUSPEND'));
return false;
// wrong syntax
}
// make sure they've entered a channel
if (trim($reason) == '') {
$reason = 'No reason';
}
// is there a reason? if not we set it to 'No Reason'
if ($channel = services::chan_exists($chan, array('channel', 'suspended'))) {
if ($channel->suspended == 1) {
services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_SUSPEND_2, array('chan' => $chan));
return false;
// channel is already suspended lol
} else {
database::update('chans', array('suspended' => 1, 'suspend_reason' => $reason), array('channel', '=', $channel->channel));
// channel isn't suspended, but it IS registered
}
} else {
$chan_info = array('channel' => $chan, 'timestamp' => core::$network_time, 'last_timestamp' => core::$network_time, 'suspended' => 1, 'suspend_reason' => $reason);
database::insert('chans', $chan_info);
database::insert('chans_flags', array('channel' => $chan, 'flags' => 'd', 'desc' => $reason));
// if the channel isn't registered, we register it, with a founder value of 0
// so we can check when it's unsuspended THAT if the founder value is 0, we'll
// just drop it as well, this way nobody actually gets the founder status.
}
services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_SUSPEND_3, array('chan' => $chan, 'reason' => $reason));
core::alog(core::$config->chanserv->nick . ': ' . $nick . ' SUSPENDED ' . $chan . ' with the reason: ' . $reason);
ircd::globops(core::$config->chanserv->nick, $nick . ' SUSPENDED ' . $chan);
if (!empty(core::$chans[$chan]['users'])) {
foreach (core::$chans[$chan]['users'] as $user => $boolean) {
if (!core::$nicks[$nick]['ircop']) {
ircd::kick(core::$config->chanserv->nick, $user, $chan, $reason);
}
}
}
// any users in the channel? KICK EM!! RAWR
}
示例6: suspend_command
public static function suspend_command($nick, $ircdata = array())
{
$unick = core::get_nick(&$ircdata, 0);
$reason = core::get_data_after(&$ircdata, 1);
$user_info = array();
// get the nick etc.
if (!core::$nicks[$nick]['ircop'] || services::user_exists($nick, true, array('display', 'identified')) === false) {
services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ACCESS_DENIED);
return false;
}
// they've gotta be identified and opered..
if (services::is_root($unick) && !services::is_root($nick)) {
services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ACCESS_DENIED);
return false;
}
// is a non-root trying to drop a root?
if (trim($reason) == '') {
$reason = 'No reason';
}
// is there a reason? if not we set it to 'No Reason'
if ($user = services::user_exists($unick, false, array('display', 'suspended'))) {
if ($user->suspended == 1) {
services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_2, array('nick' => $unick));
return false;
// channel is already suspended lol
} else {
database::update('users', array('suspended' => 1, 'suspend_reason' => $reason), array('display', '=', $user->display));
// channel isn't suspended, but it IS registered
}
} else {
$user_info = array('display' => $unick, 'last_timestamp' => core::$network_time, 'timestamp' => core::$network_time, 'identified' => 0, 'real_user' => 0, 'suspended' => 1, 'suspend_reason' => $reason);
// setup the user info array.
database::insert('users', $user_info);
// insert it into the database.
}
services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_3, array('nick' => $unick, 'reason' => $reason));
core::alog(core::$config->nickserv->nick . ': ' . $nick . ' SUSPENDED ' . $unick . ' with the reason: ' . $reason);
ircd::globops(core::$config->nickserv->nick, $nick . ' SUSPENDED ' . $unick);
if (isset(core::$nicks[$unick])) {
$random_nick = 'Unknown' . rand(10000, 99999);
services::communicate(core::$config->nickserv->nick, $unick, &nickserv::$help->NS_SUSPEND_1, array('nick' => $unick));
services::communicate(core::$config->nickserv->nick, $unick, &nickserv::$help->NS_NICK_CHANGE, array('nick' => $random_nick));
ircd::svsnick($unick, $random_nick, core::$network_time);
}
// is the nick in use? we need to force change it.
}
示例7: add
public function add()
{
// First, add the new school_year to [school_years] table:
$columns = array('school_year');
$table = new simple_table_ops();
$table->set_table_name('school_years');
$table->set_table_column_names($columns);
$table->add();
// then, gets the last inserted id (not through lastInsertedId function, because it may be buggy:
/*
SELECT article, dealer, price
FROM shop
WHERE price=(SELECT MAX(price) FROM shop);
*/
$sql = "SELECT school_year_id, school_year\n FROM school_years\n WHERE school_year_id=(SELECT MAX(school_year_id) FROM school_years)\n ";
$school_years_handle = new database();
$new_school_year_result = $school_years_handle->query($sql);
$new_school_year_id = $new_school_year_result[0]['school_year_id'];
$new_school_year = $new_school_year_result[0]['school_year'];
/* Populate automatically [courses] table with values from level_id and $_SESSION['current_school_year_id'] */
$levels_handler = new database();
$sql = "SELECT level_id FROM levels";
$result = $levels_handler->query($sql);
$insert_sql = "INSERT INTO courses (school_year_id, level_id) VALUES (?, ?)";
foreach ($result as $row) {
foreach ($row as $value) {
// insert $value into courses and $_SESSION['current_school_year_id']
$data = array($new_school_year_id, $value);
$levels_handler->insert($insert_sql, $data);
}
}
// Update current_school_year_id to the newly added school_year:
$_SESSION['current_school_year_id'] = $new_school_year_id;
$_SESSION['current_school_year'] = $new_school_year;
header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=index");
}
示例8: acl_add
public function acl_add()
{
if (isset($_POST['checkbox_array'])) {
$selected_controllers = $_POST['checkbox_array'];
$profile_id = $_POST['profile_id'];
$active_id = $_POST['active_id'];
$columns = 'controller_id, profile_id, active_id';
$sql = "INSERT INTO acl (" . $columns . ") VALUES (?, ?, ?)";
$connection = new database();
foreach ($selected_controllers as $controller_id) {
$data[] = array($controller_id, $profile_id, $active_id);
//$connection->insert($sql, $data);
}
$connection->insert($sql, $data);
}
header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=acl_index");
$columns = array('controller_id', 'profile_id', 'active_id');
$table = new simple_table_ops();
$table->set_table_name('acl');
$table->set_table_column_names($columns);
$table->add();
header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=acl_index");
}
示例9: database
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$db = new database();
$value_pc = array("name" => trim($_POST['name']), "codename" => trim($_POST['codename']), "created" => date('Y-m-d H:i:s'));
$query_pc = $db->insert("product_categories", $value_pc);
if ($query_pc == TRUE) {
header("location:" . $baseUrl . "/back/productcategorie");
}
mysql_close();
}
示例10: base_path
<?php
require base_path() . "/library/uploadimg.php";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$db = new database();
if (checkimg() == TRUE) {
$filename = date('YmdHis') . rand(0, 9);
$type = end(explode(".", $_FILES["image"]["name"]));
$image = $filename . "." . $type;
$path = base_path() . "/upload/product/";
uploadimg($filename, 600, 600, $path);
uploadimg("thumb_" . $filename, 400, 400, $path);
uploadimg("md_" . $filename, 150, 150, $path);
uploadimg("sm_" . $filename, 70, 70, $path);
} else {
$image = "ecimage.jpg";
}
$value_pd = array("name" => trim($_POST['name']), "price" => trim($_POST['price']), "brandname" => trim($_POST['brandname']), "detail" => trim($_POST['detail']), "created" => date('Y-m-d H:i:s'), "image" => $image, "product_categorie_id" => trim($_POST['product_categorie_id']));
$query_pd = $db->insert("products", $value_pd);
if ($query_pd == TRUE) {
header("location:" . $baseUrl . "/back/product");
}
mysql_close();
}
示例11: elseif
if ($exten == "s") {
$res = $db->query("SELECT * FROM user_settings WHERE name='phone_main_incomming' AND value='true' GROUP BY user_id");
} elseif (substr($exten, 0, 3) == '101') {
$exten_orig = $exten;
$exten = substr($exten, 3);
$res = $db->query("SELECT * FROM user_settings WHERE name='phone_extention' AND value='{$exten}' GROUP BY user_id");
echo "SELECT * FROM user_settings WHERE name='phone_extention' AND value='{$exten}' GROUP BY user_id";
}
//$action = "RING";
$phone_number = substr($phone_number, -10);
while ($row = $db->fetch_assoc($res)) {
$user_id = $row['user_id'];
switch (strtoupper($action)) {
case "RING":
$db->query("DELETE FROM currentcalls WHERE user_id = '{$user_id}'");
$db->insert("currentcalls", array("direction" => $direction, "call_id" => $call_id, "user_id" => $row['user_id'], 'phone_number' => $phone_number, 'exten' => $exten, 'status' => 'RING', 'ip_address' => $ip));
$ok = "OK";
break;
case "ANSWER":
//$db->query("DELETE FROM currentcalls WHERE call_id='$call_id' AND user_id <> '$user_id'");
$sql = "UPDATE currentcalls SET status = 'ANSWER', exten = '{$exten}' WHERE call_id = '{$call_id}' AND user_id = '{$user_id}'";
echo $sql . "\n";
$db->query($sql);
$ok = "OK";
break;
case "HANGUP":
$db->query("DELETE FROM currentcalls WHERE call_id = '{$call_id}' AND user_id = '{$user_id}'");
$ok = "OK";
break;
}
}
示例12: addCommission
/**
*
* @param type $data (agent_id, ads_pin, subject, from, type, amount, date_release, date, remarks, f)
* @return type boolean
*/
private static function addCommission($data)
{
$db = new database(DBTYPE, DBHOST, DBNAME, DBUSER, DBPASS);
$result = $db->insert("user_commissions", $data);
return $result;
}
示例13: move
public function move()
{
// receives array from input form
// if (isset($_POST['students'])) {
// $selected_students = $_POST['students'];
// foreach ($selected_students as $student_id) {
// echo $student_id.'<br>';
// }
// }
// builds array (
if (isset($_POST['checkbox_array'])) {
$course_id = $_POST['course_id'];
$selected_students = $_POST['checkbox_array'];
$columns = 'course_id, student_id';
$sql = "INSERT INTO classes (" . $columns . ") VALUES (?, ?)";
$connection = new database();
foreach ($selected_students as $student_id) {
$data[] = array($course_id, $student_id);
//$connection->insert($sql, $data);
}
$connection->insert($sql, $data);
}
header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=index");
}
示例14: database
$dbm4 = new database();
$dbm4->debug($m4dbdebug);
$dbm4->connect($m4dbhost, $m4dbuser, $m4dbpass, $m4dbname);
$db->select("id, tag");
$db->from("{$dbprefix}equipes, {$dbprefix}participe");
$db->where("{$dbprefix}equipes.id = {$dbprefix}participe.equipe");
$db->where("tournois = {$s_tournois}");
$db->order_by("id");
$res = $db->exec();
while ($equipes = $db->fetch($res)) {
/*** suppression de l'equipe dans m4 (eviter les conflits d'id) ***/
$dbm4->delete("m4_clan");
$dbm4->where("numero = {$equipes->id}");
$dbm4->exec();
/*** insertion de l'equipe inscrites dans m4 ***/
$dbm4->insert("m4_clan (numero,nom)");
$dbm4->values("{$equipes->id},'{$equipes->tag}'");
$dbm4->exec();
}
}
/*** redirection ***/
if (type_tournois($s_tournois) == 'E') {
js_goto("?page=finales&op=admin");
} else {
js_goto("?page=poules&op=admin");
}
} elseif ($op == "valider_poules") {
/*** test de la session ***/
if (empty($s_tournois)) {
js_goto("?page=index");
}
示例15: explode
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$pay_date_explode = explode("/", trim($_POST['pay_date']));
$pay_date = $pay_date_explode[2] . "-" . $pay_date_explode[1] . "-" . $pay_date_explode[0] . " " . trim($_POST['pay_time']);
$db = new database();
$value_pm = array("pay_money" => trim($_POST['pay_money']), "pay_date" => $pay_date, "detail" => trim($_POST['detail']), "order_id" => $_POST['order_id']);
$query_pm = $db->insert("payments", $value_pm);
if ($query_pm == TRUE) {
$db->update("orders", array("order_status" => "payments"), "id='{$_POST['order_id']}'");
header("location:" . $baseUrl . "/back/order");
}
mysql_close();
}