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


PHP sql_array函数代码示例

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


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

示例1: HookAction_datesPagestoolscron_copy_hitcountAddplugincronjob

function HookAction_datesPagestoolscron_copy_hitcountAddplugincronjob()
{
    global $lang, $action_dates_restrictfield, $action_dates_deletefield, $resource_deletion_state, $action_dates_reallydelete, $action_dates_email_admin_days, $email_notify, $email_from, $applicationname;
    $allowable_fields = sql_array("select ref as value from resource_type_field where type in (4,6,10)");
    # Check that this is a valid date field to use
    if (in_array($action_dates_restrictfield, $allowable_fields)) {
        $restrict_resources = sql_query("select resource, value from resource_data where resource_type_field = '{$action_dates_restrictfield}'");
        $emailrefs = array();
        foreach ($restrict_resources as $resource) {
            $ref = $resource["resource"];
            if ($action_dates_email_admin_days != "") {
                $action_dates_email_admin_seconds = intval($action_dates_email_admin_days) * 60 * 60 * 24;
                if (time() >= strtotime($resource["value"]) - $action_dates_email_admin_seconds && time() <= strtotime($resource["value"]) - $action_dates_email_admin_seconds + 86400) {
                    $emailrefs[] = $ref;
                }
            }
            if (time() >= strtotime($resource["value"])) {
                # Restrict access to the resource as date has been reached
                $existing_access = sql_value("select access as value from resource where ref='{$ref}'", "");
                if ($existing_access == 0) {
                    echo "restricting resource " . $ref . "\r\n";
                    sql_query("update resource set access=1 where ref='{$ref}'");
                    resource_log($ref, 'a', '', $lang['action_dates_restrict_logtext'], $existing_access, 1);
                }
            }
        }
        if (count($emailrefs) > 0) {
            global $baseurl;
            # Send email as the date is within the specified number of days
            $subject = $lang['action_dates_email_subject'];
            $message = str_replace("%%DAYS", $action_dates_email_admin_days, $lang['action_dates_email_text']) . "\r\n";
            $message .= $baseurl . "?r=" . implode("\r\n" . $baseurl . "?r=", $emailrefs) . "\r\n";
            $templatevars['message'] = $message;
            echo "Sending email to " . $email_notify . "\r\n";
            send_mail($email_notify, $subject, $message, $applicationname, $email_from, "emailexpiredresources", $templatevars, $applicationname);
        }
    }
    if (in_array($action_dates_deletefield, $allowable_fields)) {
        $delete_resources = sql_query("select resource, value from resource_data where resource_type_field = '{$action_dates_deletefield}'");
        foreach ($delete_resources as $resource) {
            $ref = $resource["resource"];
            if (time() >= strtotime($resource["value"])) {
                # Delete the resource as date has been reached
                echo "deleting resource " . $ref . "\r\n";
                if ($action_dates_reallydelete) {
                    delete_resource($ref);
                } else {
                    if (!isset($resource_deletion_state)) {
                        $resource_deletion_state = 3;
                    }
                    sql_query("update resource set archive='" . $resource_deletion_state . "' where ref='" . $ref . "'");
                }
                # Remove the resource from any collections
                sql_query("delete from collection_resource where resource='{$ref}'");
                resource_log($ref, 'x', '', $lang['action_dates_delete_logtext']);
            }
        }
    }
}
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:59,代码来源:pagestoolscron_copy_hitcount.php

示例2: HookGrant_editEditeditbeforeheader

function HookGrant_editEditeditbeforeheader()
{
    global $ref, $baseurl, $usergroup, $grant_edit_groups, $collection;
    // Do we have access to do any of this, or is it a template
    if (!in_array($usergroup, $grant_edit_groups) || $ref < 0) {
        return;
    }
    // Check for Ajax POST to delete users
    $grant_edit_action = getvalescaped("grant_edit_action", "");
    if ($grant_edit_action != "") {
        if ($grant_edit_action == "delete") {
            $remove_user = escape_check(getvalescaped("remove_user", "", TRUE));
            if ($remove_user != "") {
                sql_query("delete from grant_edit where resource='{$ref}' and user={$remove_user}");
                exit("SUCCESS");
            }
        }
        exit("FAILED");
    }
    # If 'users' is specified (i.e. access is private) then rebuild users list
    $users = getvalescaped("users", false);
    if ($users != false) {
        # Build a new list and insert
        $users = resolve_userlist_groups($users);
        $ulist = array_unique(trim_array(explode(",", $users)));
        $urefs = sql_array("select ref value from user where username in ('" . join("','", $ulist) . "')");
        if (count($urefs) > 0) {
            $inserttext = array();
            $grant_edit_expiry = getvalescaped("grant_edit_expiry", "");
            foreach ($urefs as $uref) {
                if ($grant_edit_expiry != "") {
                    $inserttext[] = $uref . ",'" . $grant_edit_expiry . "'";
                } else {
                    $inserttext[] = $uref . ",NULL";
                }
            }
            if ($collection != "") {
                global $items;
                foreach ($items as $collection_resource) {
                    sql_query("delete from grant_edit where resource='{$collection_resource}' and user in (" . implode(",", $urefs) . ")");
                    sql_query("insert into grant_edit(resource,user,expiry) values ({$collection_resource}," . join("),(" . $collection_resource . ",", $inserttext) . ")");
                    #log this
                    global $lang;
                    resource_log($collection_resource, 's', "", "Grant Edit -  " . $users . " - " . $lang['expires'] . ": " . ($grant_edit_expiry != "" ? nicedate($grant_edit_expiry) : $lang['never']));
                }
            } else {
                sql_query("delete from grant_edit where resource='{$ref}' and user in (" . implode(",", $urefs) . ")");
                sql_query("insert into grant_edit(resource,user,expiry) values ({$ref}," . join("),(" . $ref . ",", $inserttext) . ")");
                #log this
                global $lang;
                resource_log($ref, 's', "", "Grant Edit -  " . $users . " - " . $lang['expires'] . ": " . ($grant_edit_expiry != "" ? nicedate($grant_edit_expiry) : $lang['never']));
            }
        }
    }
    return true;
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:56,代码来源:edit.php

示例3: HookAction_datesPagestoolscron_copy_hitcountAddplugincronjob

function HookAction_datesPagestoolscron_copy_hitcountAddplugincronjob()
	{
	global $lang, $action_dates_restrictfield,$action_dates_deletefield, $resource_deletion_state, $action_dates_reallydelete;
	
	
	$allowable_fields=sql_array("select ref as value from resource_type_field where type in (4,6,10)");
	# Check that this is a valid date field to use
	if(in_array($action_dates_restrictfield, $allowable_fields))
		{
		$restrict_resources=sql_query("select resource, value from resource_data where resource_type_field = '$action_dates_restrictfield'");
		
		foreach ($restrict_resources as $resource)
			{
			$ref=$resource["resource"];
			if (time()>=strtotime($resource["value"]))		
				{
				# Restrict access to the resource as date has been reached
				$existing_access=sql_value("select access as value from resource where ref='$ref'","");
				if($existing_access==0) # Only apply to resources that are currently open
					{
					echo "restricting resource " . $ref ."\r\n";
					sql_query("update resource set access=1 where ref='$ref'");
					resource_log($ref,'a','',$lang['action_dates_restrict_logtext'],$existing_access,1);		
					}
				}
			}
		}
	if(in_array($action_dates_deletefield, $allowable_fields))
		{
		$delete_resources=sql_query("select resource, value from resource_data where resource_type_field = '$action_dates_deletefield'");
		foreach ($delete_resources as $resource)
			{
			$ref=$resource["resource"];
			if (time()>=strtotime($resource["value"]))		
				{
				# Delete the resource as date has been reached
				echo "deleting resource " . $ref ."\r\n";
				if ($action_dates_reallydelete)
					{
					delete_resource($ref);
					}
				else
					{
					if (!isset($resource_deletion_state)){$resource_deletion_state=3;}
					sql_query("update resource set archive='" . $resource_deletion_state . "' where ref='" . $ref . "'");
					}
				# Remove the resource from any collections
				sql_query("delete from collection_resource where resource='$ref'");
				resource_log($ref,'x','',$lang['action_dates_delete_logtext']);			
				}	
			}
		}
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:53,代码来源:pagestoolscron_copy_hitcount.php

示例4: check_defensio_comment

function check_defensio_comment()
{
    global $pixelpost_db_prefix, $cfgrow, $parent_id, $message, $ip, $name, $url, $email;
    $defensio_conf = sql_array("SELECT * FROM {$pixelpost_db_prefix}defensio");
    // the following code tries to get the full addon path.
    $filename = basename(__FILE__, ".php");
    $query = "SELECT `addon_name` FROM `{$pixelpost_db_prefix}addons` WHERE `addon_name` LIKE '%" . $filename . "%'";
    $result = mysql_query($query) or die(mysql_error());
    while ($row = mysql_fetch_array($result)) {
        $addon_path = $row[0];
    }
    $pos = strpos($addon_path, "/");
    if ($pos === false) {
        $addon_path = null;
    } else {
        $addon_path = substr($addon_path, 0, $pos);
    }
    $defensio_conf['addon_path'] = "addons/" . $addon_path;
    // build $comment array used for testing.
    $comment = array();
    $comment['owner-url'] = $defensio_conf['blog'];
    $comment['user-ip'] = $ip;
    $comment['comment_post_ID'] = $parent_id;
    $comment['permalink'] = $defensio_conf['blog'] . "index.php?showimage=" . $parent_id;
    $comment['comment-type'] = 'comment';
    $comment['comment-author'] = $name;
    $comment['comment-content'] = $message;
    $comment['comment-author-email'] = $email;
    $comment['comment-author-url'] = $url;
    $comment['referrer'] = $_SERVER['HTTP_REFERER'];
    //$comment['trusted-user'] = 'true';
    // get the date/time of the original posting
    $query = "SELECT `datetime` FROM `{$pixelpost_db_prefix}pixelpost` WHERE `id` = '" . $parent_id . "'";
    $result = mysql_query($query) or die(mysql_error());
    if (mysql_num_rows($result) == 1) {
        // check comment
        while ($row = mysql_fetch_array($result)) {
            $comment['article-date'] = gmdate("Y/m/d", $row[0]);
        }
        defensio_check_comment_front($defensio_conf, $comment);
    } else {
        // trying to comment on a non-existent blog post
        header("HTTP/1.0 404 Not Found");
        header("Status: 404 File Not Found!");
        echo "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"><HTML><HEAD>\n<TITLE>404 Not Found</TITLE>\n</HEAD><BODY>\n<H1>Not Found</H1>\nThe comment could not be accepted because the blogpost doesn't exists.<P>\n<P>Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.\n</BODY></HTML>";
        exit;
    }
}
开发者ID:RoseySoft,项目名称:pixelpost,代码行数:48,代码来源:front_defensio.php

示例5: getThemeList

function getThemeList($parents = array())
{
    if (count($parents) == 0) {
        // just retrieve all the top level themes
        $sql = "select distinct theme as value from collection where theme is not null and theme <> '' order by theme";
    } else {
        // we were passed an array of parents, so we need to narrow our search
        for ($i = 1; $i < count($parents) + 1; $i++) {
            if ($i == 1) {
                $searchfield = 'theme';
            } else {
                $searchfield = "theme{$i}";
            }
            $whereclause = "{$searchfield} = '" . escape_check($parents[$i - 1]) . "' ";
        }
        $sql = "select distinct theme{$i} as value from collection where {$whereclause} and theme{$i} is not null and theme{$i} <> '' order by theme{$i}";
        //echo $sql;
    }
    $result = sql_array($sql);
    return $result;
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:21,代码来源:themelevel_add.php

示例6: getFeed

 public function getFeed($who, $limit = 50, $offset = 0)
 {
     if (!is_array($who)) {
         $who = array($who);
     }
     $who_array = $who;
     foreach ($who_array as $who) {
         if ($who_csv) {
             $who_csv .= ',';
         }
         $who_csv .= "'{$who}'";
     }
     // return a distinct field in a table with an order by
     $where = "who in ( {$who_csv} )";
     $order_by = 'news_who.insert_time desc';
     $person_id = PERSON_ID ? PERSON_ID : 0;
     $sql = "\n            SELECT news_item_id FROM (\n                SELECT DISTINCT ON (q.news_item_id) news_item_id, row FROM (\n                    SELECT\n                        news_who.news_item_id,\n                        row_number() OVER (ORDER BY {$order_by}) AS row\n                    FROM news_who\n                    LEFT JOIN news_hide on news_hide.news_item_id = news_who.news_item_id\n                        and news_hide.person_id = {$person_id}\n                        and news_hide.active = 1\n                    LEFT JOIN news_item on news_item.id = news_who.news_item_id\n                    WHERE news_who.active = 1\n                    AND news_item.active = 1\n                    AND news_hide.id is null\n                    AND {$where}\n                    ORDER BY {$order_by}\n                    OFFSET {$offset}\n                    LIMIT {$limit}\n                ) AS q\n            ) AS fin ORDER BY row";
     //print_pre($sql);
     elapsed('before news query');
     $arr = sql_array($sql);
     elapsed('after news query');
     return $arr;
 }
开发者ID:hshoghi,项目名称:cms,代码行数:23,代码来源:class.news.php

示例7: get_theme_image

function get_theme_image($themes=array())
	{
	# Returns an array of resource references that can be used as theme category images.
	global $theme_images_number;
	global $theme_category_levels;
	# First try to find resources that have been specifically chosen using the option on the collection comments page.
	$sql="select r.ref value from collection c join collection_resource cr on c.ref=cr.collection join resource r on cr.resource=r.ref where c.theme='" . escape_check($themes[0]) . "' ";
	for ($n=2;$n<=count($themes)+1;$n++){
		if (isset($themes[$n-1])){
			$sql.=" and theme".$n."='" . escape_check($themes[$n-1]) . "' ";
		} 
		else {
			if ($n<=$theme_category_levels){
				$sql.=" and (theme".$n."='' or theme".$n." is null) ";
			}
		}
	} 

	$sql.=" and r.has_image=1 and cr.use_as_theme_thumbnail=1 order by r.ref desc";
	$chosen=sql_array($sql,0);
	if (count($chosen)>0) {return $chosen;}
	
	# No chosen images? Manually choose a single image based on hit counts.
	$sql="select r.ref value from collection c join collection_resource cr on c.ref=cr.collection join resource r on cr.resource=r.ref where c.theme='" . escape_check($themes[0]) . "' ";
	for ($n=2;$n<=count($themes)+1;$n++){
		if (isset($themes[$n-1])){
			$sql.=" and theme".$n."='" . escape_check($themes[$n-1]) . "' ";
		} 
		else {
			if ($n<=$theme_category_levels){
			$sql.=" and (theme".$n."='' or theme".$n." is null) ";
			}
		}
	} 
	$sql.=" and r.has_image=1 order by r.hit_count desc limit " . $theme_images_number;
	$images=sql_array($sql,0);

	$tmp = hook("getthemeimage", "", array($themes)); if($tmp!==false and is_array($tmp) and count($tmp)>0) $images = $tmp;

	if (count($images)>0) {return $images;}
	return false;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:42,代码来源:collections_functions.php

示例8: display_field_data

function display_field_data($field, $valueonly = false, $fixedwidth = 452)
{
    global $ref, $fieldcount, $tabcount, $show_expiry_warning, $access, $tabname, $search, $extra, $lang, $used_tab_names, $related_type_show_with_data, $show_default_related_resources;
    $value = $field["value"];
    $modified_field = hook("beforeviewdisplayfielddata_processing", "", array($field));
    if ($modified_field) {
        $field = $modified_field;
    }
    # Handle expiry fields
    if (!$valueonly && $field["type"] == 6 && $value != "" && $value <= date("Y-m-d H:i") && $show_expiry_warning) {
        $extra .= "<div class=\"RecordStory\"> <h1>" . $lang["warningexpired"] . "</h1><p>" . $lang["warningexpiredtext"] . "</p><p id=\"WarningOK\"><a href=\"#\" onClick=\"document.getElementById('RecordDownload').style.display='block';document.getElementById('WarningOK').style.display='none';\">" . $lang["warningexpiredok"] . "</a></p></div><style>#RecordDownload {display:none;}</style>";
    }
    if ($value != "" && $value != "," && $field["display_field"] == 1 && ($access == 0 || $access == 1 && !$field["hide_when_restricted"])) {
        if (!$valueonly) {
            $title = htmlspecialchars(str_replace("Keywords - ", "", $field["title"]));
        } else {
            $title = "";
        }
        //if ($field["type"]==4 || $field["type"]==6) {$value=NiceDate($value,false,true);}
        # Value formatting
        if ($field["type"] == 2 || $field["type"] == 7 || $field["type"] == 9) {
            $i18n_split_keywords = true;
        } else {
            $i18n_split_keywords = false;
        }
        $value = i18n_get_translated($value, $i18n_split_keywords);
        if ($field["type"] == 2 || $field["type"] == 3 || $field["type"] == 7 || $field["type"] == 9) {
            $value = TidyList($value);
        }
        $value_unformatted = $value;
        # store unformatted value for replacement also
        if ($field["type"] != 8 || $field["type"] == 8 && $value == strip_tags($value)) {
            $value = nl2br(htmlspecialchars($value));
        }
        $modified_value = hook('display_field_modified_value', '', array($field));
        if ($modified_value) {
            $value = $modified_value['value'];
        }
        # draw new tab panel?
        if (!$valueonly && $tabname != $field["tab_name"] && $fieldcount > 0) {
            $resource_type_tab_names = sql_array('SELECT tab_name as value FROM resource_type', '');
            $resource_type_tab_names = array_filter($resource_type_tab_names);
            # Display related resources on this tab, if set:
            if (isset($related_type_show_with_data)) {
                # NOTE: the resource type tab name and the current tab you are on need to be the same:
                if (in_array($tabname, $resource_type_tab_names)) {
                    if (($key = array_search($tabname, $resource_type_tab_names)) !== false) {
                        # Fields with display template should be rendered before the related resources list:
                        echo $extra;
                        $extra = '';
                        include '../include/related_resources.php';
                        unset($resource_type_tab_names[$key]);
                        $show_default_related_resources = FALSE;
                    }
                }
            }
            $tabcount++;
            # Also display the custom formatted data $extra at the bottom of this tab panel.
            ?>
<div class="clearerleft"> </div><?php 
            echo $extra;
            ?>
</div></div><div class="TabbedPanel StyledTabbedPanel" style="display:none;" id="tab<?php 
            echo $tabcount;
            ?>
"><div><?php 
            $extra = "";
        }
        $tabname = $field["tab_name"];
        $used_tab_names[] = $tabname;
        $used_tab_names = array_unique($used_tab_names);
        $fieldcount++;
        if (!$valueonly && trim($field["display_template"]) != "") {
            # Process the value using a plugin
            $plugin = "../plugins/value_filter_" . $field["name"] . ".php";
            if ($field['value_filter'] != "") {
                eval($field['value_filter']);
            } else {
                if (file_exists($plugin)) {
                    include $plugin;
                } else {
                    if ($field["type"] == 4 || $field["type"] == 6) {
                        $value = NiceDate($value, false, true);
                    }
                }
            }
            # Highlight keywords
            $value = highlightkeywords($value, $search, $field["partial_index"], $field["name"], $field["keywords_index"]);
            # Use a display template to render this field
            $template = $field["display_template"];
            $template = str_replace("[title]", $title, $template);
            $template = str_replace("[value]", $value, $template);
            $template = str_replace("[value_unformatted]", $value_unformatted, $template);
            $template = str_replace("[ref]", $ref, $template);
            $extra .= $template;
        } else {
            #There is a value in this field, but we also need to check again for a current-language value after the i18n_get_translated() function was called, to avoid drawing empty fields
            if ($value != "") {
                # Draw this field normally.
                # value filter plugin should be used regardless of whether a display template is used.
//.........这里部分代码省略.........
开发者ID:claytondaley,项目名称:resourcespace,代码行数:101,代码来源:view.php

示例9: getvalescaped

 }
 $archive = getvalescaped("archive", "");
 if ($archive != "" && checkperm('e' . $archive)) {
     $status = $archive;
 } else {
     if (checkperm("c")) {
         $status = 0;
     } else {
         if (checkperm("d")) {
             $status = -2;
         }
     }
 }
 # Else, set status to Pending Submission.
 // check required fields
 $required_fields = sql_array("select ref value from resource_type_field where required=1 and (resource_type='{$resource_type}' or resource_type='0')");
 $missing_fields = false;
 $error_message = "";
 foreach ($required_fields as $required_field) {
     $value = getvalescaped("field" . $required_field, "");
     if ($value == '') {
         $fieldname = i18n_get_translated(sql_value("select title value from resource_type_field where ref='{$required_field}'", ""));
         $options = sql_value("select options value from resource_type_field where ref='{$required_field}'", "");
         $type = sql_value("select type value from resource_type_field where ref='{$required_field}'", "");
         if ($options != "" && ($type == 3 || $type == 2)) {
             $optionstring = "Allowed Values: " . ltrim(implode("\n", explode(",", $options)), ",") . "\n";
         } else {
             $optionstring = "";
         }
         $error_message .= "{$fieldname} is required. Use field{$required_field}=[string] as a parameter. {$optionstring}\n";
         $missing_fields = true;
开发者ID:claytondaley,项目名称:resourcespace,代码行数:31,代码来源:index.php

示例10: update_disk_usage_cron

function update_disk_usage_cron()
	{
	# Update disk usage for all resources that have not yet been updated or have not been updated in the past 30 days.
	# Limit to a reasonable amount so that this process is spread over several cron intervals for large data sets.
	$resources=sql_array("select ref value from resource where ref>0 and disk_usage_last_updated is null or datediff(now(),disk_usage_last_updated)>30 limit 20000");
	foreach ($resources as $resource)
		{
		update_disk_usage($resource);
		}
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:10,代码来源:resource_functions.php

示例11: sql_query

sql_query("delete from resource_keyword where resource not in (select ref from resource)");
echo sql_affected_rows() . " orphaned resource-keyword relationships deleted.<br/><br/>";
sql_query("delete from keyword where ref not in (select keyword from resource_keyword) and ref not in (select keyword from keyword_related) and ref not in (select related from keyword_related) and ref not in (select keyword from collection_keyword)");
echo sql_affected_rows() . " unused keywords deleted.<br/><br/>";
sql_query("delete from resource_alt_files where resource not in (select ref from resource)");
echo sql_affected_rows() . " orphaned alternative files deleted.<br/><br/>";
sql_query("delete from resource_custom_access where resource not in (select ref from resource) or (user not in (select ref from user) and usergroup not in (select ref from usergroup))");
echo sql_affected_rows() . " orphaned resource custom access rows deleted.<br/><br/>";
sql_query("delete from resource_dimensions where resource not in (select ref from resource)");
echo sql_affected_rows() . " orphaned resource dimension rows deleted.<br/><br/>";
sql_query("delete from resource_log where resource<>0 and resource not in (select ref from resource)");
echo sql_affected_rows() . " orphaned resource log rows deleted.<br/><br/>";
sql_query("delete from resource_related where resource not in (select ref from resource) or related not in (select ref from resource)");
echo sql_affected_rows() . " orphaned resource related rows deleted.<br/><br/>";
sql_query("delete from resource_type_field where resource_type<>999 and resource_type<>0 and resource_type not in (select ref from resource_type)");
echo sql_affected_rows() . " orphaned fields deleted.<br/><br/>";
sql_query("delete from user_collection where user not in (select ref from user) or collection not in (select ref from collection)");
echo sql_affected_rows() . " orphaned user-collection relationships deleted.<br/><br/>";
sql_query("delete from resource_data where resource not in (select ref from resource) or resource_type_field not in (select ref from resource_type_field)");
echo sql_affected_rows() . " orphaned resource data rows deleted.<br/><br/>";
# Clean out and resource data that is set for fields not applicable to a given resource type.
$r = get_resource_types();
for ($n = 0; $n < count($r); $n++) {
    $rt = $r[$n]["ref"];
    $fields = sql_array("select ref value from resource_type_field where resource_type=0 or resource_type=999 or resource_type='" . $rt . "'");
    if (count($fields) > 0) {
        sql_query("delete from resource_data where resource in (select ref from resource where resource_type='{$rt}') and resource_type_field not in (" . join(",", $fields) . ")");
        echo sql_affected_rows() . " orphaned resource data rows deleted for resource type {$rt}.<br/><br/>";
    }
}
hook("dbprune");
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:31,代码来源:database_prune.php

示例12: sql_query

sql_query("DELETE FROM resource_keyword WHERE resource NOT IN (SELECT ref FROM resource)");
echo number_format(sql_affected_rows()) . " orphaned resource-keyword relationships deleted." . $newline;
sql_query("DELETE FROM keyword WHERE ref NOT IN (SELECT keyword FROM resource_keyword) AND ref NOT IN (SELECT keyword FROM keyword_related) AND ref NOT IN (SELECT related FROM keyword_related) AND ref NOT IN (SELECT keyword FROM collection_keyword)");
echo number_format(sql_affected_rows()) . " unused keywords deleted." . $newline;
sql_query("DELETE FROM resource_alt_files WHERE resource NOT IN (SELECT ref FROM resource)");
echo number_format(sql_affected_rows()) . " orphaned alternative files deleted." . $newline;
sql_query("DELETE FROM resource_custom_access WHERE resource NOT IN (SELECT ref FROM resource) OR (user NOT IN (SELECT ref FROM user) AND usergroup NOT IN (SELECT ref FROM usergroup))");
echo number_format(sql_affected_rows()) . " orphaned resource custom access rows deleted." . $newline;
sql_query("DELETE FROM resource_dimensions WHERE resource NOT IN (SELECT ref FROM resource)");
echo number_format(sql_affected_rows()) . " orphaned resource dimension rows deleted." . $newline;
sql_query("DELETE FROM resource_log WHERE resource<>0 AND resource NOT IN (SELECT ref FROM resource)");
echo number_format(sql_affected_rows()) . " orphaned resource log rows deleted." . $newline;
sql_query("DELETE FROM resource_related WHERE resource NOT IN (SELECT ref FROM resource) OR related NOT IN (SELECT ref FROM resource)");
echo number_format(sql_affected_rows()) . " orphaned resource related rows deleted." . $newline;
sql_query("DELETE FROM resource_type_field WHERE resource_type<>999 AND resource_type<>0 AND resource_type NOT IN (SELECT ref FROM resource_type)");
echo number_format(sql_affected_rows()) . " orphaned fields deleted." . $newline;
sql_query("DELETE FROM user_collection WHERE user NOT IN (SELECT ref FROM user) OR collection NOT IN (SELECT ref FROM collection)");
echo number_format(sql_affected_rows()) . " orphaned user-collection relationships deleted." . $newline;
sql_query("DELETE FROM resource_data WHERE resource NOT IN (SELECT ref FROM resource) OR resource_type_field NOT IN (SELECT ref FROM resource_type_field)");
echo number_format(sql_affected_rows()) . " orphaned resource data rows deleted." . $newline;
# Clean out and resource data that is set for fields not applicable to a given resource type.
$r = get_resource_types();
for ($n = 0; $n < count($r); $n++) {
    $rt = $r[$n]["ref"];
    $fields = sql_array("SELECT ref value FROM resource_type_field WHERE resource_type=0 OR resource_type=999 OR resource_type='" . $rt . "'");
    if (count($fields) > 0) {
        sql_query("DELETE FROM resource_data WHERE resource in (SELECT ref FROM resource WHERE resource_type='{$rt}') AND resource_type_field NOT IN (" . join(",", $fields) . ")");
        echo number_format(sql_affected_rows()) . " orphaned resource data rows deleted for resource type {$rt}." . $newline;
    }
}
hook("dbprune");
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:31,代码来源:database_prune.php

示例13: repetidos

    $repetidos = repetidos($conexion, "nombre_categoria", strtoupper($_POST['nombre_categoria']), "categoria", "g", "", "");
    if ($repetidos == 'true') {
        $data = "1";
        /// este dato ya existe;
    } else {
        $sql = "insert into categoria values ('{$id}','" . strtoupper($_POST['nombre_categoria']) . "','{$fecha}','1')";
        $guardar = guardarSql($conexion, $sql);
        $sql_nuevo = "select (id_categoria,nombre_categoria,fecha_creacion,estado) from categoria where id_categoria = '{$id}'";
        $sql_nuevo = sql_array($conexion, $sql_nuevo);
        auditoria_sistema($conexion, 'categoria', $id_user, 'Insert', $id, $fecha_larga, $fecha, $sql_nuevo, '');
        $data = "2";
    }
} else {
    if ($_POST['oper'] == "edit") {
        $repetidos = repetidos($conexion, "nombre_categoria", strtoupper($_POST['nombre_categoria']), "categoria", "m", $_POST['id'], "id_categoria");
        if ($repetidos == 'true') {
            $data = "1";
            /// este dato ya existe;
        } else {
            $sql_anterior = "select (id_categoria,nombre_categoria,fecha_creacion,estado) from categoria where id_categoria = '{$_POST['id']}'";
            $sql_anterior = sql_array($conexion, $sql_anterior);
            $sql = "update categoria set nombre_categoria = '" . strtoupper($_POST['nombre_categoria']) . "', fecha_creacion = '{$fecha}' where id_categoria = '{$_POST['id']}'";
            $guardar = guardarSql($conexion, $sql);
            $sql_nuevo = "select (id_categoria,nombre_categoria,fecha_creacion,estado) from categoria where id_categoria = '{$_POST['id']}'";
            $sql_nuevo = sql_array($conexion, $sql_nuevo);
            auditoria_sistema($conexion, 'categoria', $id_user, 'Update', $_POST['id'], $fecha_larga, $fecha, $sql_nuevo, $sql_anterior);
            $data = "3";
        }
    }
}
echo $data;
开发者ID:Oskrin,项目名称:neltex_formulario,代码行数:31,代码来源:categorias.php

示例14: eval_addon_admin_workspace_menu

     $moderate_where = " and publish='no' ";
     $moderate_where2 = " WHERE publish='no' ";
 }
 if (isset($_GET['show']) and $_GET['show'] == 'published') {
     $moderate_where = " and publish='yes' ";
     $moderate_where2 = " WHERE publish='yes' ";
 }
 $order_by = " ORDER BY id DESC ";
 // the $moderate_where and $order_by statements can now be overridden by using an addon and the following workspace:
 // new workspace added! For correct page number with other buttons
 eval_addon_admin_workspace_menu('pages_commentbuttons');
 // count comments!
 $commentnumb = sql_array("select count(*) as count from " . $pixelpost_db_prefix . "comments" . $moderate_where2);
 $pixelpost_commentnumb = $commentnumb['count'];
 // get the number of comments in moderation
 $commentnumb_moderation = sql_array("select count(*) as count from " . $pixelpost_db_prefix . "comments  WHERE publish='no' ");
 // display submenu
 echo "<div id='submenu'>";
 $submenucssclass = 'notselected';
 if (!isset($_GET['show']) || $_GET['show'] == 'published') {
     $submenucssclass = 'selectedsubmenu';
 }
 if (isset($_GET['commentsview'])) {
     $submenucssclass = 'notselected';
 }
 echo "<a href='index.php?view=comments&amp;show=published' class='" . $submenucssclass . "'>" . $admin_lang_cmnt_submenu1 . "</a>\n";
 $submenucssclass = 'notselected';
 echo "|";
 if (isset($_GET['show']) && $_GET['show'] == 'masked') {
     $submenucssclass = 'selectedsubmenu';
 }
开发者ID:RoseySoft,项目名称:pixelpost,代码行数:31,代码来源:comments.php

示例15: exit

            }
        } else {
            exit("Unknown argv: " . $argv[1]);
        }
    }
}
# Check for a process lock
if (is_process_lock("staticsync")) {
    echo 'Process lock is in place. Deferring.' . PHP_EOL;
    echo 'To clear the lock after a failed run use --clearlock flag.' . PHP_EOL;
    exit;
}
set_process_lock("staticsync");
echo "Preloading data... ";
$count = 0;
$done = sql_array("SELECT file_path value FROM resource WHERE LENGTH(file_path)>0 AND file_path LIKE '%/%'");
$done = array_flip($done);
# Load all modification times into an array for speed
$modtimes = array();
$resource_modified_times = sql_query("SELECT file_modified, file_path FROM resource WHERE archive=0 AND LENGTH(file_path) > 0");
foreach ($resource_modified_times as $rmd) {
    $modtimes[$rmd["file_path"]] = $rmd["file_modified"];
}
$lastsync = sql_value("SELECT value FROM sysvars WHERE name='lastsync'", "");
$lastsync = strlen($lastsync) > 0 ? strtotime($lastsync) : '';
echo "done." . PHP_EOL;
echo "Looking for changes..." . PHP_EOL;
# Pre-load the category tree, if configured.
if (isset($staticsync_mapped_category_tree)) {
    $field = get_field($staticsync_mapped_category_tree);
    $tree = explode("\n", trim($field["options"]));
开发者ID:vachanda,项目名称:ResourceSpace,代码行数:31,代码来源:staticsync.php


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