当前位置: 首页>>代码示例>>PHP>>正文


PHP insert_data函数代码示例

本文整理汇总了PHP中insert_data函数的典型用法代码示例。如果您正苦于以下问题:PHP insert_data函数的具体用法?PHP insert_data怎么用?PHP insert_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了insert_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的insert_data函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。