本文整理汇总了PHP中insert_data函数的典型用法代码示例。如果您正苦于以下问题:PHP insert_data函数的具体用法?PHP insert_data怎么用?PHP insert_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了insert_data函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: add_to_river
/**
* Adds an item to the river.
*
* @param string $view The view that will handle the river item (must exist)
* @param string $action_type An arbitrary one-word string to define the action (eg 'comment', 'create')
* @param int $subject_guid The GUID of the entity doing the action
* @param int $object_guid The GUID of the entity being acted upon
* @param int $access_id The access ID of the river item (default: same as the object)
* @param int $posted The UNIX epoch timestamp of the river item (default: now)
* @return true|false Depending on success
*/
function add_to_river($view, $action_type, $subject_guid, $object_guid, $access_id = "", $posted = 0)
{
// Sanitise variables
if (!elgg_view_exists($view)) {
return false;
}
if (!($subject = get_entity($subject_guid))) {
return false;
}
if (!($object = get_entity($object_guid))) {
return false;
}
if (empty($action_type)) {
return false;
}
if ($posted == 0) {
$posted = time();
}
if ($access_id === "") {
$access_id = $object->access_id;
}
$type = $object->getType();
$subtype = $object->getSubtype();
$action_type = sanitise_string($action_type);
// Load config
global $CONFIG;
// Attempt to save river item; return success status
return insert_data("insert into {$CONFIG->dbprefix}river " . " set type = '{$type}', " . " subtype = '{$subtype}', " . " action_type = '{$action_type}', " . " access_id = {$access_id}, " . " view = '{$view}', " . " subject_guid = {$subject_guid}, " . " object_guid = {$object_guid}, " . " posted = {$posted} ");
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:40,代码来源:river2.php
示例2: add_to_river
/**
* Adds an item to the river.
*
* @param string $view The view that will handle the river item (must exist)
* @param string $action_type An arbitrary one-word string to define the action (eg 'comment', 'create')
* @param int $subject_guid The GUID of the entity doing the action
* @param int $object_guid The GUID of the entity being acted upon
* @param int $access_id The access ID of the river item (default: same as the object)
* @param int $posted The UNIX epoch timestamp of the river item (default: now)
* @return true|false Depending on success
*/
function add_to_river($view, $action_type, $subject_guid, $object_guid, $access_id = "", $posted = 0, $annotation_id = 0)
{
// Sanitise variables
if (!elgg_view_exists($view)) {
return false;
}
if (!($subject = get_entity($subject_guid))) {
return false;
}
if (!($object = get_entity($object_guid))) {
return false;
}
if (empty($action_type)) {
return false;
}
if ($posted == 0) {
$posted = time();
}
if ($access_id === "") {
$access_id = $object->access_id;
}
$annotation_id = (int) $annotation_id;
$type = $object->getType();
$subtype = $object->getSubtype();
$action_type = sanitise_string($action_type);
// Load config
global $CONFIG;
// Attempt to save river item; return success status
$insert_data = insert_data("insert into {$CONFIG->dbprefix}river " . " set type = '{$type}', " . " subtype = '{$subtype}', " . " action_type = '{$action_type}', " . " access_id = {$access_id}, " . " view = '{$view}', " . " subject_guid = {$subject_guid}, " . " object_guid = {$object_guid}, " . " annotation_id = {$annotation_id}, " . " posted = {$posted} ");
//update the entities which had the action carried out on it
if ($insert_data) {
update_entity_last_action($object_guid, $posted);
return $insert_data;
}
}
开发者ID:adamboardman,项目名称:Elgg,代码行数:46,代码来源:river2.php
示例3: add_entity_relationship
/**
* Define an arbitrary relationship between two entities.
* This relationship could be a friendship, a group membership or a site membership.
*
* This function lets you make the statement "$guid_one is a $relationship of $guid_two".
*
* @param int $guid_one First GUID
* @param string $relationship Relationship name
* @param int $guid_two Second GUID
*
* @return bool
* @throws InvalidArgumentException
*/
function add_entity_relationship($guid_one, $relationship, $guid_two)
{
global $CONFIG;
if (strlen($relationship) > ElggRelationship::RELATIONSHIP_LIMIT) {
$msg = "relationship name cannot be longer than " . ElggRelationship::RELATIONSHIP_LIMIT;
throw InvalidArgumentException($msg);
}
$guid_one = (int) $guid_one;
$relationship = sanitise_string($relationship);
$guid_two = (int) $guid_two;
$time = time();
// Check for duplicates
if (check_entity_relationship($guid_one, $relationship, $guid_two)) {
return false;
}
$id = insert_data("INSERT INTO {$CONFIG->dbprefix}entity_relationships\n\t\t(guid_one, relationship, guid_two, time_created)\n\t\tVALUES ({$guid_one}, '{$relationship}', {$guid_two}, {$time})");
if ($id !== false) {
$obj = get_relationship($id);
// this event has been deprecated in 1.9. Use 'create', 'relationship'
$result_old = elgg_trigger_event('create', $relationship, $obj);
$result = elgg_trigger_event('create', 'relationship', $obj);
if ($result && $result_old) {
return true;
} else {
delete_relationship($result);
}
}
return false;
}
开发者ID:tjcaverly,项目名称:Elgg,代码行数:42,代码来源:relationships.php
示例4: testCanInsertData
public function testCanInsertData()
{
_elgg_services()->db->addQuerySpec(['sql' => 'INSERT INTO A WHERE b = :b', 'params' => [':b' => 'b'], 'insert_id' => 123]);
_elgg_services()->db->addQuerySpec(['sql' => 'INSERT INTO A WHERE c = :c', 'params' => [':c' => 'c']]);
$this->assertEquals(123, insert_data('INSERT INTO A WHERE b = :b', [':b' => 'b']));
$this->assertEquals(0, insert_data('INSERT INTO A WHERE c = :c', [':c' => 'c']));
}
开发者ID:elgg,项目名称:elgg,代码行数:7,代码来源:DatabaseTest.php
示例5: addTaggedWirePost
function addTaggedWirePost($hook, $type, $params)
{
global $CONFIG;
$id = insert_data("insert into {$CONFIG->dbprefix}river " . " set type = '" . $params['type'] . "', " . " subtype = '" . $params['subtype'] . "', " . " action_type = '" . $params['action_type'] . "', " . " access_id = '" . $params['access_id'] . "', " . " view = '" . $params['view'] . "', " . " subject_guid = '" . $params['subject_guid'] . "', " . " object_guid = '" . $params['object_guid'] . "', " . " annotation_id = '" . $params['annotation_id'] . "', " . " posted = '" . $params['posted'] . "';");
$tags = "";
if (isset($_SESSION['role'])) {
switch ($_SESSION['role']) {
case "learner":
$tags = "Learner-Apprenant";
break;
case "instructor":
$tags = "Instructor-Instructeur";
break;
case "developer":
$tags = "Developer-Développeur";
break;
case "trainingmgr":
$tags = "trainingmgr";
break;
}
$roleTags = $_SESSION['role'];
}
if ($roleTags) {
$metaID = create_metadata($params['object_guid'], "tags", "{$tags}", "text", elgg_get_logged_in_user_guid(), 2, true);
}
if ($id) {
update_entity_last_action($object_guid, $posted);
$river_items = elgg_get_river(array('id' => $id));
if ($river_items) {
elgg_trigger_event('created', 'river', $river_items[0]);
}
}
return false;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:34,代码来源:start.php
示例6: create_object_entity
/**
* Create or update the extras table for a given object.
* Call create_entity first.
*
* @param int $guid The guid of the entity you're creating (as obtained by create_entity)
* @param string $title The title of the object
* @param string $description The object's description
*
* @return bool
*/
function create_object_entity($guid, $title, $description)
{
global $CONFIG;
$guid = (int) $guid;
$title = sanitise_string($title);
$description = sanitise_string($description);
$row = get_entity_as_row($guid);
if ($row) {
// Core entities row exists and we have access to it
$query = "SELECT guid from {$CONFIG->dbprefix}objects_entity where guid = {$guid}";
if ($exists = get_data_row($query)) {
$query = "UPDATE {$CONFIG->dbprefix}objects_entity\n\t\t\t\tset title='{$title}', description='{$description}' where guid={$guid}";
$result = update_data($query);
if ($result != false) {
// Update succeeded, continue
$entity = get_entity($guid);
elgg_trigger_event('update', $entity->type, $entity);
return $guid;
}
} else {
// Update failed, attempt an insert.
$query = "INSERT into {$CONFIG->dbprefix}objects_entity\n\t\t\t\t(guid, title, description) values ({$guid}, '{$title}','{$description}')";
$result = insert_data($query);
if ($result !== false) {
$entity = get_entity($guid);
if (elgg_trigger_event('create', $entity->type, $entity)) {
return $guid;
} else {
$entity->delete();
}
}
}
}
return false;
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:45,代码来源:objects.php
示例7: save
/**
* Save a key
*
* @param string $key Name
* @param string $data Value
*
* @return boolean
*/
public function save($key, $data)
{
$dbprefix = elgg_get_config('dbprefix');
$key = sanitise_string($key);
$time = time();
$query = "INSERT into {$dbprefix}hmac_cache (hmac, ts) VALUES ('{$key}', '{$time}')";
return insert_data($query);
}
开发者ID:elgg,项目名称:elgg,代码行数:16,代码来源:ElggHMACCache.php
示例8: save
/**
* Save a key
*
* @param string $key Name
* @param string $data Value
*
* @return boolean
*/
public function save($key, $data)
{
global $CONFIG;
$key = sanitise_string($key);
$time = time();
$query = "INSERT into {$CONFIG->dbprefix}hmac_cache (hmac, ts) VALUES ('{$key}', '{$time}')";
return insert_data($query);
}
开发者ID:ibou77,项目名称:elgg,代码行数:16,代码来源:ElggHMACCache.php
示例9: add
function add($conn)
{
//echo "you got add";
$realname = $_GET["real_name"];
$user = $_GET["user"];
$pass = $_GET["pass"];
insert_data($conn, $realname, $user, $pass);
}
开发者ID:ruochenliao,项目名称:Myproject,代码行数:8,代码来源:id_table.php
示例10: add
function add($conn)
{
$employee = $_GET["employee"];
$product = $_GET["product"];
$brand = $_GET["brand"];
$quantity = $_GET["quantity"];
$price = $_GET["price"];
insert_data($conn, $employee, $product, $brand, $quantity, $price);
}
开发者ID:ruochenliao,项目名称:Myproject,代码行数:9,代码来源:input_table.php
示例11: eg_chat_post
function eg_chat_post($chatp_guid, $chat_post)
{
error_log('here is chatpost - ' . $chat_post);
$userid = elgg_get_logged_in_user_guid();
$query = "insert into `chathistory` (`to_guid`,`from_guid`,`message`,`date`) values('" . $chatp_guid . "','" . $userid . "','" . $chat_post . "','" . date('Y-m-d H:i') . "')";
insert_data($query);
$last_record_id = "select `id` from `chathistory` where `from_guid`=" . $userid . " order by id desc limit 1";
$aj = get_data($last_record_id);
return json_encode($aj);
}
开发者ID:enraiser,项目名称:engap,代码行数:10,代码来源:start.php
示例12: create
/**
* Generate a new API user for a site, returning a new keypair on success
* @return \hypeJunction\Graph\ApiUser|false
*/
public function create()
{
$public = sha1(rand() . $this->site_guid . microtime());
$secret = sha1(rand() . $this->site_guid . microtime() . $public);
$insert = insert_data("INSERT into {$this->dbprefix}api_users\n\t\t\t\t\t\t\t\t(site_guid, api_key, secret) values\n\t\t\t\t\t\t\t\t({$this->site_guid}, '{$public}', '{$secret}')");
if (empty($insert)) {
return false;
}
return $this->get($public);
}
开发者ID:hypejunction,项目名称:hypegraph,代码行数:14,代码来源:KeysService.php
示例13: add_to_river
/**
* Adds an item to the river.
*
* @param string $view The view that will handle the river item (must exist)
* @param string $action_type An arbitrary string to define the action (eg 'comment', 'create')
* @param int $subject_guid The GUID of the entity doing the action
* @param int $object_guid The GUID of the entity being acted upon
* @param int $access_id The access ID of the river item (default: same as the object)
* @param int $posted The UNIX epoch timestamp of the river item (default: now)
* @param int $annotation_id The annotation ID associated with this river entry
*
* @return int/bool River ID or false on failure
*/
function add_to_river($view, $action_type, $subject_guid, $object_guid, $access_id = "", $posted = 0, $annotation_id = 0)
{
global $CONFIG;
// use default viewtype for when called from web services api
if (!elgg_view_exists($view, 'default')) {
return false;
}
if (!($subject = get_entity($subject_guid))) {
return false;
}
if (!($object = get_entity($object_guid))) {
return false;
}
if (empty($action_type)) {
return false;
}
if ($posted == 0) {
$posted = time();
}
if ($access_id === "") {
$access_id = $object->access_id;
}
$type = $object->getType();
$subtype = $object->getSubtype();
$view = sanitise_string($view);
$action_type = sanitise_string($action_type);
$subject_guid = sanitise_int($subject_guid);
$object_guid = sanitise_int($object_guid);
$access_id = sanitise_int($access_id);
$posted = sanitise_int($posted);
$annotation_id = sanitise_int($annotation_id);
$values = array('type' => $type, 'subtype' => $subtype, 'action_type' => $action_type, 'access_id' => $access_id, 'view' => $view, 'subject_guid' => $subject_guid, 'object_guid' => $object_guid, 'annotation_id' => $annotation_id, 'posted' => $posted);
// return false to stop insert
$values = elgg_trigger_plugin_hook('creating', 'river', null, $values);
if ($values == false) {
// inserting did not fail - it was just prevented
return true;
}
extract($values);
// Attempt to save river item; return success status
$id = insert_data("insert into {$CONFIG->dbprefix}river " . " set type = '{$type}', " . " subtype = '{$subtype}', " . " action_type = '{$action_type}', " . " access_id = {$access_id}, " . " view = '{$view}', " . " subject_guid = {$subject_guid}, " . " object_guid = {$object_guid}, " . " annotation_id = {$annotation_id}, " . " posted = {$posted}");
// update the entities which had the action carried out on it
// @todo shouldn't this be down elsewhere? Like when an annotation is saved?
if ($id) {
update_entity_last_action($object_guid, $posted);
$river_items = elgg_get_river(array('id' => $id));
if ($river_items) {
elgg_trigger_event('created', 'river', $river_items[0]);
}
return $id;
} else {
return false;
}
}
开发者ID:rcolomoc,项目名称:Master-Red-Social,代码行数:67,代码来源:river.php
示例14: create_api_user
/**
* Generate a new API user for a site, returning a new keypair on success.
*
* @return stdClass object or false
*/
function create_api_user()
{
$dbprefix = elgg_get_config('dbprefix');
$public = _elgg_services()->crypto->getRandomString(40, ElggCrypto::CHARS_HEX);
$secret = _elgg_services()->crypto->getRandomString(40, ElggCrypto::CHARS_HEX);
$insert = insert_data("INSERT into {$dbprefix}api_users\n\t\t(api_key, secret) values\n\t\t('{$public}', '{$secret}')");
if ($insert) {
return get_api_user($public);
}
return false;
}
开发者ID:elgg,项目名称:elgg,代码行数:16,代码来源:api_user.php
示例15: gc_err_logging
function gc_err_logging($errMess, $errStack, $applName, $errType)
{
$DBprefix = elgg_get_config('dbprefix');
$errDate = date("Y-m-d H:i:s");
$servername = gethostname();
$username = elgg_get_logged_in_user_entity()->username;
$user_guid = elgg_get_logged_in_user_entity()->guid;
$serverip = $_SERVER['REMOTE_ADDR'];
$sql = 'INSERT INTO ' . $DBprefix . 'elmah_log (appl_name,error_type,server_name,server_ip,user_guid,time_created,username,error_messages,error_stacktrace) VALUES ("' . $applName . '","' . $errType . '","' . $servername . '","' . $serverip . '","' . $user_guid . '","' . $errDate . '","' . $username . '","' . $errMess . '","' . $errStack . '")';
insert_data($sql);
}
开发者ID:smellems,项目名称:wet4,代码行数:11,代码来源:logging.php
示例16: create
/**
* Obtain a token for a user
*
* @param ElggUser $user User entity
* @param ElggSite $site Site entity token applies to
* @param int $expire Minutes until token expires (default is 60 minutes)
* @return UserToken|false
*/
public function create(ElggUser $user, ElggSite $site, $expire = self::DEFAULT_EXPIRES)
{
$time = time();
$time += 60 * $expire;
$token = md5(sha1(rand() . microtime() . $user->username . $time . $site->guid));
$result = insert_data("INSERT into {$this->dbprefix}users_apisessions\n\t\t\t\t(user_guid, site_guid, token, expires) values\n\t\t\t\t({$user->guid}, {$site->guid}, '{$token}', '{$time}')\n\t\t\t\ton duplicate key update token='{$token}', expires='{$time}'");
if (!$result) {
return false;
}
return UserToken::load($token);
}
开发者ID:hypejunction,项目名称:hypegraph,代码行数:19,代码来源:TokenService.php
示例17: set_config
/**
* Sets a configuration value
*
* @param string $name The name of the configuration value
* @param string $value Its value
* @param int $site_guid Optionally, the GUID of the site (current site is assumed by default)
* @return 0
* @todo The config table doens't have numeric primary keys so insert_data returns 0.
*/
function set_config($name, $value, $site_guid = 0)
{
global $CONFIG;
// Unset existing
unset_config($name, $site_guid);
$site_guid = (int) $site_guid;
if ($site_guid == 0) {
$site_guid = (int) $CONFIG->site_id;
}
$CONFIG->{$name} = $value;
$value = sanitise_string(serialize($value));
return insert_data("insert into {$CONFIG->dbprefix}config set name = '{$name}', value = '{$value}', site_guid = {$site_guid}");
}
开发者ID:adamboardman,项目名称:Elgg,代码行数:22,代码来源:configuration.php
示例18: testCanInsert
public function testCanInsert()
{
$time = time();
$id1 = insert_data("\n\t\t\tINSERT INTO {$this->prefix}entity_relationships\n\t\t\t (guid_one, relationship, guid_two, time_created)\n\t\t\tVALUES ({$this->user->guid}, 'test_self1', {$this->user->guid}, {$time})\n\t\t\tON DUPLICATE KEY UPDATE time_created = {$time}\n\t\t");
$id2 = insert_data("\n\t\t\tINSERT INTO {$this->prefix}entity_relationships\n\t\t\t (guid_one, relationship, guid_two, time_created)\n\t\t\tVALUES (:guid1, :rel, :guid2, :time)\n\t\t\tON DUPLICATE KEY UPDATE time_created = :time\n\t\t", [':guid1' => $this->user->guid, ':guid2' => $this->user->guid, ':rel' => 'test_self2', ':time' => $time]);
$rows = get_data("\n\t\t\tSELECT *\n\t\t\tFROM {$this->prefix}entity_relationships\n\t\t\tWHERE guid_one = ?\n\t\t\t AND guid_two = ?\n\t\t\t AND time_created = ?\n\t\t\tORDER BY id ASC\n\t\t", null, [$this->user->guid, $this->user->guid, $time]);
$this->assertIsA($id1, 'int');
$this->assertIsA($id2, 'int');
$this->assertEqual($rows[0]->id, $id1);
$this->assertEqual($rows[1]->id, $id2);
remove_entity_relationship($this->user->guid, 'test_self1', $this->user->guid);
remove_entity_relationship($this->user->guid, 'test_self2', $this->user->guid);
}
开发者ID:elgg,项目名称:elgg,代码行数:13,代码来源:ElggDataFunctionsTest.php
示例19: create_user_token
/**
* Obtain a token for a user.
*
* @param string $username The username
* @param int $expire Minutes until token expires (default is 60 minutes)
*
* @return bool
*/
function create_user_token($username, $expire = 60)
{
$dbprefix = elgg_get_config('dbprefix');
$user = get_user_by_username($username);
$time = time() + 60 * $expire;
$token = _elgg_services()->crypto->getRandomString(32, ElggCrypto::CHARS_HEX);
if (!$user) {
return false;
}
if (insert_data("INSERT into {$dbprefix}users_apisessions\n\t\t\t\t(user_guid, token, expires) values\n\t\t\t\t({$user->guid}, '{$token}', '{$time}')\n\t\t\t\ton duplicate key update token='{$token}', expires='{$time}'")) {
return $token;
}
return false;
}
开发者ID:elgg,项目名称:elgg,代码行数:22,代码来源:tokens.php
示例20: entity_view_counter_add_view
function entity_view_counter_add_view(ElggEntity $entity)
{
if (entity_view_counter_is_counted($entity)) {
return;
}
if (is_memcache_available()) {
$cache = new ElggMemcache('entity_view_counter');
$key = "view_" . session_id() . "_" . $entity->guid;
$cache->save($key, 1);
}
$guid = (int) $entity->guid;
$type = sanitise_string($entity->type);
$subtype = (int) $entity->subtype;
insert_data("\r\n \tINSERT INTO elgg_entity_views (guid, type, subtype, container_guid, site_guid, views)\r\n \tVALUES ({$guid}, '{$type}', {$subtype}, {$entity->container_guid}, {$entity->site_guid}, 1)\r\n \tON DUPLICATE KEY UPDATE views = views + 1;\r\n ");
}
开发者ID:pleio,项目名称:entity_view_counter,代码行数:15,代码来源:functions.php
注:本文中的insert_data函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论