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


PHP sql_insert_id函数代码示例

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


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

示例1: do_upload

function do_upload($tid)
{
    global $nick;
    if ($_FILES['attachment-file']['size'] < 1) {
        return "File size is too small!";
    }
    $file_name = $_FILES['attachment-file']['name'];
    $file_ext = strtolower(substr($file_name, -4));
    if ($file_ext != ".jpg" && $file_ext != ".png" && $file_ext != ".pdf" && $file_ext != ".log" && $file_ext != ".txt") {
        return "You can only upload jpg/png/pdf/log/txt files!";
    }
    $file_type = $_FILES['attachment-file']['type'];
    $file_size = $_FILES['attachment-file']['size'];
    $file_desc = "Attachment by " . $nick;
    if (!is_numeric($file_size)) {
        safe_die("Error! Invalid number in file size!");
    }
    $query = squery("INSERT INTO karnaf_files(tid,file_name,file_type,file_desc,file_size,lastupd_time) VALUES(%d,'%s','%s','%s',%d,%d)", $tid, $file_name, $file_type, $file_desc, $file_size, time());
    if (!$query) {
        return "SQL Error! Query failed on do_upload() function: " . mysql_error();
    }
    $id = sql_insert_id();
    $fn = KARNAF_UPLOAD_PATH . "/" . $tid;
    if (!file_exists($fn)) {
        if (!mkdir($fn)) {
            return "Can't create attachment directory!";
        }
    }
    $fn .= "/" . $id . $file_ext;
    if (!copy($_FILES['attachment-file']['tmp_name'], $fn)) {
        return "Couldn't create attachment file!";
    }
    return "";
}
开发者ID:nirn,项目名称:karnaf,代码行数:34,代码来源:view.php

示例2: send_research_request

 function send_research_request()
 {
     # Insert a search request into the requests table.
     # Resolve resource types
     $rt = "";
     $types = get_resource_types();
     for ($n = 0; $n < count($types); $n++) {
         if (getval("resource" . $types[$n]["ref"], "") != "") {
             if ($rt != "") {
                 $rt .= ", ";
             }
             $rt .= $types[$n]["ref"];
         }
     }
     global $userref;
     $as_user = getvalescaped("as_user", $userref, true);
     # If userref submitted, use that, else use this user
     # Insert the request
     sql_query("insert into research_request(created,user,name,description,deadline,contact,email,finaluse,resource_types,noresources,shape)\n\tvalues (now(),'{$as_user}','" . getvalescaped("name", "") . "','" . getvalescaped("description", "") . "'," . (getvalescaped("deadline", "") == "" ? "null" : "'" . getvalescaped("deadline", "") . "'") . ",'" . getvalescaped("contact", "") . "','" . getvalescaped("email", "") . "','" . getvalescaped("finaluse", "") . "','" . $rt . "'," . (getvalescaped("noresources", "") == "" ? "null" : "'" . getvalescaped("noresources", "") . "'") . ",'" . getvalescaped("shape", "") . "')");
     # E-mails a resource request (posted) to the team
     global $applicationname, $email_from, $baseurl, $email_notify, $username, $userfullname, $useremail, $lang;
     $templatevars['ref'] = sql_insert_id();
     $templatevars['teamresearchurl'] = $baseurl . "/pages/team/team_research.php";
     $templatevars['username'] = $username;
     $templatevars['userfullname'] = $userfullname;
     $templatevars['useremail'] = getvalescaped("email", $useremail);
     # Use provided e-mail (for anonymous access) or drop back to user email.
     $templatevars['url'] = $baseurl . "/pages/team/team_research_edit.php?ref=" . $templatevars['ref'];
     $message = "'{$username}' ({$userfullname} - {$useremail}) " . $lang["haspostedresearchrequest"] . ".\n\n";
     $message .= $templatevars['teamresearchurl'];
     hook("modifyresearchrequestemail");
     send_mail($email_notify, $applicationname . ": " . $lang["newresearchrequestwaiting"], $message, $useremail, "", "emailnewresearchrequestwaiting", $templatevars);
 }
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:33,代码来源:research_functions.php

示例3: create_dash_tile

function create_dash_tile($url, $link, $title, $reload_interval, $all_users, $default_order_by, $resource_count, $text = "", $delete = 1)
{
    $rebuild_order = TRUE;
    # Validate Parameters
    if (empty($reload_interval) || !is_numeric($reload_interval)) {
        $reload_interval = 0;
    }
    $delete = $delete ? 1 : 0;
    $all_users = $all_users ? 1 : 0;
    if (!is_numeric($default_order_by)) {
        $default_order_by = append_default_position();
        $rebuild_order = FALSE;
    }
    $resource_count = $resource_count ? 1 : 0;
    # De-Duplication of tiles on creation
    $existing = sql_query("SELECT ref FROM dash_tile WHERE url='" . $url . "' AND link='" . $link . "' AND title='" . escape_check($title) . "' AND txt='" . escape_check($text) . "' AND reload_interval_secs=" . $reload_interval . " AND all_users=" . $all_users . " AND resource_count=" . $resource_count);
    if (isset($existing[0]["ref"])) {
        $tile = $existing[0]["ref"];
        $rebuild_order = FALSE;
    } else {
        $result = sql_query("INSERT INTO dash_tile (url,link,title,reload_interval_secs,all_users,default_order_by,resource_count,allow_delete,txt) VALUES ('" . $url . "','" . $link . "','" . escape_check($title) . "'," . $reload_interval . "," . $all_users . "," . $default_order_by . "," . $resource_count . "," . $delete . ",'" . escape_check($text) . "')");
        $tile = sql_insert_id();
    }
    # If tile already existed then this no reorder
    if ($rebuild_order) {
        reorder_default_dash();
    }
    if ($all_users == 1) {
        sql_query("DELETE FROM user_dash_tile WHERE dash_tile=" . $tile);
        $result = sql_query("INSERT user_dash_tile (user,dash_tile,order_by) SELECT user.ref,'" . $tile . "',5 FROM user");
    }
    return $tile;
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:33,代码来源:dash_functions.php

示例4: create_fact

function create_fact($fact_type, $book_id, $fields)
{
    sql_begin();
    sql_pe("INSERT INTO facts\n        VALUES (NULL, ?, ?, ?)", array($book_id, $user_id, $fact_type));
    $fact_id = sql_insert_id();
    add_field_values($fact_id, $fact_type, $fields);
    sql_commit();
}
开发者ID:ayunah,项目名称:opencorpora,代码行数:8,代码来源:lib_facts.php

示例5: createNew

 /**
  * Creates a new template
  *
  * (static)
  */
 function createNew($name, $desc)
 {
     global $manager;
     $manager->notify('PreAddTemplate', array('name' => &$name, 'description' => &$desc));
     sql_query('INSERT INTO ' . sql_table('template_desc') . " (tdname, tddesc) VALUES ('" . sql_real_escape_string($name) . "','" . sql_real_escape_string($desc) . "')");
     $newId = sql_insert_id();
     $manager->notify('PostAddTemplate', array('templateid' => $newId, 'name' => $name, 'description' => $desc));
     return $newId;
 }
开发者ID:hatone,项目名称:Nucleus-v3.64,代码行数:14,代码来源:TEMPLATE.php

示例6: insert_room

 function insert_room($idConference, $user_email, $display_name, $confkey, $audiovideosettings, $maxmikes, $maxparticipants, $startdate, $starthour, $startminute, $duration, $extra_conf)
 {
     $res->result = true;
     $res = $this->api_schedule_meeting($idConference, $user_email, $display_name, $confkey, $audiovideosettings, $maxmikes, $maxparticipants, $startdate, $starthour, $startminute, $duration, $extra_conf);
     if ($res && $res->result) {
         require_once _base_ . '/lib/lib.json.php';
         $json = new Services_JSON();
         //save in database the roomid for user login
         $insert_room = "\r\n\t\t\tINSERT INTO " . $this->_getRoomTable() . "\r\n\t\t\t( idConference,confkey,emailuser,displayname,audiovideosettings,maxmikes,schedule_info, extra_conf ) VALUES (\r\n\t\t\t\t'" . $idConference . "',\r\n\t\t\t\t'" . $confkey . "',\r\n\t\t\t\t'" . $user_email . "',\r\n\t\t\t\t'" . $display_name . "',\r\n\t\t\t\t'" . $audiovideosettings . "',\r\n\t\t\t\t'" . $maxmikes . "',\r\n\t\t\t\t'" . $json->encode($res->response) . "',\r\n\t\t\t\t'" . $json->encode($extra_conf) . "'\r\n\t\t\t)";
         if (!sql_query($insert_room)) {
             return false;
         }
         return sql_insert_id();
     }
     return false;
 }
开发者ID:abhinay100,项目名称:forma_app,代码行数:16,代码来源:lib.bbb.php

示例7: message_add

function message_add($users, $text, $url = "", $owner = null, $notification_type = MESSAGE_ENUM_NOTIFICATION_TYPE_SCREEN, $ttl_seconds = MESSAGE_DEFAULT_TTL_SECONDS)
{
    global $userref;
    $text = escape_check($text);
    $url = escape_check($url);
    if (!is_array($users)) {
        $users = array($users);
    }
    if (is_null($owner)) {
        $owner = $userref;
    }
    sql_query("INSERT INTO `message` (`owner`, `created`, `expires`, `message`, `url`) VALUES ({$owner}, NOW(), DATE_ADD(NOW(), INTERVAL {$ttl_seconds} SECOND), '{$text}', '{$url}')");
    $message_ref = sql_insert_id();
    foreach ($users as $user) {
        sql_query("INSERT INTO `user_message` (`user`, `message`) VALUES ({$user},{$message_ref})");
    }
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:17,代码来源:message_functions.php

示例8: sql_transaction

function sql_transaction($lines = array(), $return_last_insert_id = TRUE)
{
    //sql_rollback();
    sql_begin();
    if (!is_array($lines)) {
        $lines = array($lines);
    }
    foreach ($lines as $line) {
        $result = sql_query_dbg($line, true);
    }
    if (count($lines)) {
        if ($return_last_insert_id) {
            //we must get the insert id before commiting
            $ret = sql_insert_id();
        }
    }
    sql_commit();
    if (count($lines) && !$return_last_insert_id) {
        $ret = sql_affected_rows($result);
    }
    return $ret;
}
开发者ID:kalliste,项目名称:kalliste-php-framework,代码行数:22,代码来源:modify.php

示例9: addCom

function addCom($wcaid,$name,$birthday,$country,$gender,$importing=false,$id=0)
{
	global $compstable;
	//
	$name = preg_replace("~[\\\\\"\;]~","",$name);
	$wcaid = strtoupper($wcaid);
	if ($wcaid && !preg_match("/^\d{4}[A-Z]{4}\d{2}$/",$wcaid))
		return addCom_err("Invalid WCA id format",$wcaid,$name,$importing);
	if (!checkdate((int)substr($birthday,5,2),(int)substr($birthday,8,2),(int)substr($birthday,0,4)))
		return addCom_err("Invalid date [$birthday]",$wcaid,$name,$importing);
	$gender = strtolower($gender);
	if ($gender!="f" && $gender!="m")
		return addCom_err("Invalid gender",$wcaid,$name,$importing);
	//
	if ($wcaid && !$id)
	{
		$result = strict_query("SELECT * FROM $compstable WHERE WCAid=?", array($wcaid));
		if (sql_num_rows($result))
			return addCom_err("WCA id already exists",$wcaid,$name,$importing);
	}
	$result = strict_query("SELECT * FROM countries WHERE id=?", array($country));
	if (!sql_num_rows($result))
		return addCom_err("Invalid country: ".$country,$wcaid,$name,$importing);
	if (!$id)
	{
		$result = strict_query("SELECT * FROM $compstable WHERE name=? AND country_id=? AND birthday=?", array($name,$country,$birthday));
		if (sql_num_rows($result))
			return addCom_err("Competitor already inserted",$wcaid,$name,$importing);
	}
	//
	if ($id)
		strict_query("UPDATE $compstable SET WCAid=?, name=?, country_id=?, birthday=?, gender=? WHERE id=?", array($wcaid,$name,$country,$birthday,$gender,$id));
	else
		strict_query("INSERT INTO $compstable SET WCAid=?, name=?, country_id=?, birthday=?, gender=?", array($wcaid,$name,$country,$birthday,$gender));
	//
	return ($id?(int)$id:sql_insert_id());
}
开发者ID:pedrosino,项目名称:cubecomps.com,代码行数:37,代码来源:lib_com.php

示例10: sprintf

if (!$enable_mapdisplay) {
    $tpl->error(ERROR_INVALID_OPERATION);
}
$sqlchecksum = sprintf('%u', crc32($cachesFilter . "\n" . $sqlFilter));
// check if query was already executed within the cache period
$rsMapCache = sql("SELECT `result_id` FROM `map2_result` WHERE `sqlchecksum`='&1' AND DATE_ADD(`date_created`, INTERVAL '&2' SECOND)>NOW() AND `sqlquery`='&3'", $sqlchecksum, $opt['map']['maxcacheage'], $sqlFilter);
if ($rMapCache = sql_fetch_assoc($rsMapCache)) {
    $resultId = $rMapCache['result_id'];
    sql("UPDATE `map2_result` SET `shared_counter`=`shared_counter`+1 WHERE `result_id`='" . ($resultId + 0) . "'");
} else {
    // ensure that query is performed without errors before reserving the result_id
    sql_temp_table_slave('tmpmapresult');
    sql_slave("CREATE TEMPORARY TABLE &tmpmapresult (`cache_id` INT UNSIGNED NOT NULL, PRIMARY KEY (`cache_id`)) ENGINE=MEMORY");
    sql_slave("INSERT INTO &tmpmapresult (`cache_id`) " . $sqlFilter);
    sql("INSERT INTO `map2_result` (`slave_id`, `sqlchecksum`, `sqlquery`, `date_created`, `date_lastqueried`) VALUES ('&1', '&2', '&3', NOW(), NOW())", $db['slave_id'], $sqlchecksum, $cachesFilter . "\n" . $sqlFilter);
    $resultId = sql_insert_id();
    sql_slave("INSERT IGNORE INTO `map2_data` (`result_id`, `cache_id`) SELECT '&1', `cache_id` FROM &tmpmapresult", $resultId);
    sql_drop_temp_table_slave('tmpmapresult');
}
sql_free_result($rsMapCache);
if ($map2_bounds) {
    $rs = sql_slave("SELECT MIN(`latitude`) AS `lat_min`,\n\t\t                        MAX(`latitude`) AS `lat_max`,\n\t\t                        MIN(`longitude`) AS `lon_min`,\n\t\t                        MAX(`longitude`) AS `lon_max`\n                       FROM `map2_data`, `caches`\n\t                    WHERE `result_id`='&1'\n\t                      AND `caches`.`cache_id`=`map2_data`.`cache_id`", $resultId);
    if (($rBounds = sql_fetch_assoc($rs)) && $rBounds['lat_min'] !== null) {
        if ($rBounds['lat_min'] == $rBounds['lat_max'] && $rBounds['lon_min'] == $rBounds['lon_max']) {
            $halfwin = 0.02;
            $rBounds['lat_min'] -= $halfwin;
            $rBounds['lat_max'] += $halfwin;
            $rBounds['lon_min'] -= $halfwin;
            $rBounds['lon_max'] += $halfwin;
        }
        $bounds_param = "&lat_min=" . round($rBounds['lat_min'], 5) . "&lat_max=" . round($rBounds['lat_max'], 5) . '&lon_min=' . round($rBounds['lon_min'], 5) . '&lon_max=' . round($rBounds['lon_max'], 5);
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:31,代码来源:search.map2.inc.php

示例11: create_feed

    function create_feed($name_in, $group_in, $type_in = 0, $desc_in = ''){
		if($this->set == true){
			return false; //We already have a feed established here
		} else {
			//Begin testing/cleaning block
			$name_in = escape($name_in);
         $desc_in = escape($desc_in);
			if(!is_numeric($group_in) || !is_numeric($type_in)){
				$this->status = "Unknown Error"; //Aka they are playing with the post data!
				return false;
			}
			//End testing/cleaning block
			$sql = "INSERT INTO feed (name, group_id, type, description) VALUES ('$name_in', $group_in, $type_in, '$desc_in')";
            		$res = sql_query($sql);
                	if($res){
                    		$sql_id = sql_insert_id();

                    		$this->id = $sql_id;
                    		$this->name = stripslashes($name_in);
                        $this->description = stripslashes($desc_in);
                    		$this->group_id = $group_in;
				$this->type = $type_in;
							
                    		$this->set = true;

				$notify = new Notification();
	                        $notify->notify('feed', $this->id, 'group', $this->group_id, 'new');

                    		return true;
                	} else {
                    		return false;
                	}
        	}
    	}
开发者ID:TNValleyFiddlersConvention,项目名称:fiddlers,代码行数:34,代码来源:feed.php

示例12: sql_replace

         $nb_erreur++;
     }
 }
 # there is no error in submited datas
 if ($nb_erreur == 0) {
     # case : new item to add
     if (!isset($_POST['id']) or empty($_POST['id'])) {
         $sql_add = sql_replace($sql['member']['insert_country'], $_POST);
         $sgbd = sql_connect();
         $execution = sql_query($sql_add);
         if ($execution) {
             $page['L_message'] = $lang['member']['form_country_add_1'];
         } else {
             $page['L_message'] = $lang['member']['form_country_add_0'];
         }
         $page['value_id'] = sql_insert_id($sgbd);
         sql_close($sgbd);
         # si l'add vient d'une page pop, c'est que l'on vient d'un autre formulaire.
         # on va donc renvoyer l'information au formulaire parent
         if ($execution and isset($_GET['fen']) and $_GET['fen'] == "pop") {
             $page['pop'] = "1";
             $page['nouveau_text'] = $_POST['name'];
             $page['nouveau_id'] = $page['value_id'];
         }
     } else {
         $sql_modification = sql_replace($sql['member']['edit_country'], $_POST);
         $sgbd = sql_connect();
         if (sql_query($sql_modification) != false) {
             $page['L_message'] = $lang['member']['form_country_edit_1'];
         } else {
             $page['L_message'] = $lang['member']['form_country_edit_0'];
开发者ID:jkreska,项目名称:test1,代码行数:31,代码来源:country_list.php

示例13: add_smart_collection

function add_smart_collection()
{
    global $userref;
    $search = getvalescaped("addsmartcollection", "");
    $restypes = getvalescaped("restypes", "");
    if ($restypes == "Global") {
        $restypes = "";
    }
    $archive = getvalescaped("archive", "", true);
    $starsearch = getvalescaped("starsearch", 0);
    // more compact search strings should work with get_search_title
    $searchstring = array();
    if ($search != "") {
        $searchstring[] = "search={$search}";
    }
    if ($restypes != "") {
        $searchstring[] = "restypes={$restypes}";
    }
    if ($starsearch != "") {
        $searchstring[] = "starsearch={$starsearch}";
    }
    if ($archive != 0) {
        $searchstring[] = "archive={$archive}";
    }
    $searchstring = implode("&", $searchstring);
    if ($starsearch == "") {
        $starsearch = 0;
    }
    $newcollection = create_collection($userref, get_search_title($searchstring), 1);
    sql_query("insert into collection_savedsearch(collection,search,restypes,archive,starsearch) values ('{$newcollection}','" . $search . "','" . $restypes . "','" . $archive . "','" . $starsearch . "')");
    $savedsearch = sql_insert_id();
    sql_query("update collection set savedsearch='{$savedsearch}' where ref='{$newcollection}'");
    set_user_collection($userref, $newcollection);
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:34,代码来源:collections_functions.php

示例14: max

     $as_re_name = $reply_array['wr_name'];
     $as_re_mb = $reply_array['mb_id'];
 } else {
     $sql = " select max(wr_comment) as max_comment from {$write_table}\n                    where wr_parent = '{$wr_id}' and wr_is_comment = 1 ";
     $row = sql_fetch($sql);
     //$row[max_comment] -= 1;
     $row['max_comment'] += 1;
     $tmp_comment = $row['max_comment'];
     $tmp_comment_reply = '';
 }
 //럭키포인트
 $as_lucky = $board['as_lucky'] ? apms_lucky('', $bo_table, $wr_id) : 0;
 $wr_subject = get_text(stripslashes($wr['wr_subject']));
 $sql = " insert into {$write_table}\n                set ca_name = '" . addslashes($wr['ca_name']) . "',\n                     wr_option = '{$wr_secret}',\n                     wr_num = '{$wr['wr_num']}',\n                     wr_reply = '',\n                     wr_parent = '{$wr_id}',\n                     wr_is_comment = 1,\n                     wr_comment = '{$tmp_comment}',\n                     wr_comment_reply = '{$tmp_comment_reply}',\n                     wr_subject = '',\n                     wr_content = '{$wr_content}',\n                     mb_id = '{$mb_id}',\n                     wr_password = '{$wr_password}',\n                     wr_name = '{$wr_name}',\n                     wr_email = '{$wr_email}',\n                     wr_homepage = '{$wr_homepage}',\n                     wr_datetime = '" . G5_TIME_YMDHIS . "',\n                     wr_last = '',\n                     wr_ip = '{$_SERVER['REMOTE_ADDR']}',\n                     as_level = '{$as_level}',\n\t\t\t\t\t as_lucky = '{$as_lucky}',\n                     as_re_mb = '{$as_re_mb}',\n\t\t\t\t\t as_re_name = '{$as_re_name}',\n\t\t\t\t\t as_icon = '{$as_icon}',\n                     wr_1 = '{$wr_1}',\n                     wr_2 = '{$wr_2}',\n                     wr_3 = '{$wr_3}',\n                     wr_4 = '{$wr_4}',\n                     wr_5 = '{$wr_5}',\n                     wr_6 = '{$wr_6}',\n                     wr_7 = '{$wr_7}',\n                     wr_8 = '{$wr_8}',\n                     wr_9 = '{$wr_9}',\n                     wr_10 = '{$wr_10}' ";
 sql_query($sql);
 $comment_id = sql_insert_id();
 // 원글에 댓글수 증가 & 마지막 시간 반영
 sql_query(" update {$write_table} set wr_comment = wr_comment + 1, wr_last = '" . G5_TIME_YMDHIS . "' where wr_id = '{$wr_id}' ");
 sql_query(" update {$g5['board_new_table']} set as_comment = as_comment + 1 where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ", false);
 // 새글 INSERT
 if ($is_new) {
     sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id, as_lucky, as_re_mb ) values ( '{$bo_table}', '{$comment_id}', '{$wr_id}', '" . G5_TIME_YMDHIS . "', '{$member['mb_id']}', '{$as_lucky}', '{$as_re_mb}') ");
 }
 // 댓글 1 증가
 sql_query(" update {$g5['board_table']} set bo_count_comment = bo_count_comment + 1 where bo_table = '{$bo_table}' ");
 // APMS : 내글반응 등록
 if ($is_response) {
     apms_response('wr', 'comment', '', $bo_table, $wr_id, $wr_subject, $wr['mb_id'], $member['mb_id'], $wr_name, $comment_id);
     if ($response_flag == 'reply') {
         //대댓글일 때
         $pre_comment = sql_fetch(" select mb_id from {$write_table} where wr_parent = '{$wr_id}' and wr_is_comment = 1 and wr_comment = '{$tmp_comment}' and wr_comment_reply = '" . substr($tmp_comment_reply, 0, -1) . "' ");
开发者ID:peb317,项目名称:gbamn,代码行数:31,代码来源:write_comment_update.page.php

示例15: populate_metadata_from_dump

function populate_metadata_from_dump($id, $meta)
{
    global $fields_title, $fields_embeddedequiv, $fields_type, $optionlists;
    // read in the metadata file and dump it into the right places in the database
    $metadump = file_get_contents($meta);
    // lazy solution: the resourcespace XML namespace is not formally defined
    // and thus the docs will not validate. For now we're just going to do some
    // regex magic to get rid of the namespaces alltogether. Fixme - would be
    // nice to make the metadump files validate
    $metadump = preg_replace('/([<\\/])([a-z0-9]+):/i', '$1$2', $metadump);
    $metadump = preg_replace('/(resourcespace):(resourceid="\\d+">)/i', '$1$2', $metadump);
    # Fix an issue whereby the resourcespace namespace is not defined. Add a fake namespace to the header.
    $metadump = str_replace("xmlns:dc", "xmlns:resourcespace='http://www.resourcespace.org' xmlns:dc", $metadump);
    $metadump = stripInvalidXml($metadump);
    //echo $metadump;
    $xml = new SimpleXMLElement($metadump);
    //print_r($xml);
    //echo "\n field ref for title is " . $xml->dctitle['rsfieldref'] . "\n";
    foreach ($xml as $fieldxml) {
        if ($fieldxml == '') {
            continue;
        }
        $value = $fieldxml;
        $rsfieldtitle = $fieldxml['rsfieldtitle'];
        $rsembeddedequiv = $fieldxml['rsembeddedequiv'];
        $rsfieldref = $fieldxml['rsfieldref'];
        $rsfieldtype = $fieldxml['rsfieldtype'];
        echo "\n==========\n";
        echo "   rsfieldtitle: {$rsfieldtitle}\n";
        echo " rsembeddedequiv: {$rsembeddedequiv}\n";
        echo "     rsfieldref: {$rsfieldref}\n";
        echo "    rsfieldtype: {$rsfieldtype}\n";
        echo "          value: {$value}\n";
        $rsfieldtitle = escape_check($rsfieldtitle);
        $newid = sql_value("select ref value from resource_type_field where title = '{$rsfieldtitle}' and type = '{$rsfieldtype}'", 0);
        if ($newid > 0) {
            $finalid = $newid;
        } else {
            if ($rsfieldtype == '7') {
                // category trees are too complicated to construct, so we're going to treat them as text fields for now.
                $rsfieldtype = '1';
            }
            $sql = "insert into resource_type_field (title,type,name) values ('{$rsfieldtitle}','{$rsfieldtype}','{$rsembeddedequiv}')";
            $result = sql_query($sql);
            $finalid = sql_insert_id();
        }
        if ($rsfieldtype == 2 || $rsfieldtype == 3) {
            if (!isset($optionlists[$finalid])) {
                $optionlists[$finalid] = array();
            }
            if (!in_array($value, $optionlists[$finalid])) {
                $optionlists[$finalid][] = $value;
            }
        }
        $fields_title["{$rsfieldref}"] = $rsfieldtitle;
        $fields_embeddedequiv["{$rsfieldref}"] = $rsembeddedequiv;
        $fields_type["{$rsfieldref}"] = $rsfieldtype;
        $value = escape_check($value);
        $sql = "insert into resource_data (resource, resource_type_field, value) values ('{$id}','{$rsfieldref}','{$value}')";
        sql_query($sql);
    }
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:62,代码来源:recover.php


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