Location: PHPKode > projects > PhpProjectMaster > www/inc/site_value.php
<?php
/* 
For working with site_value DB table (stores misc values necessary for working site)
 (c) 2004-2007 by "Oleg Savchuk" <hide@address.com>

 part of phpProjectMaster project
 http://phpprojmaster.sourceforge.net

 The contents of this file are subject to the GNU GENERAL PUBLIC LICENSE
 http://www.gnu.org/copyleft/gpl.html
*/

require_once "sitelib.php";

// get_site_value
// set_site_value

function get_site_value_rec($item_id){

 $sql="select * from site_value where sv_id=$item_id";
 $sth=db_query($sql);

 return mysql_fetch_assoc($sth);
}

############### Return values AS STRING! caller should take care about type conversion
function get_site_value($name){

 $sql="select ivalue from site_value where iname=".db_quote($name);
 $sth=db_query($sql);
 $hr=mysql_fetch_assoc($sth);

 return $hr['ivalue'];
}

############### ALL VALUES STORED AS STRINGS!
function set_site_value($name, $value){

 $sql="replace into site_value (iname, ivalue, upd_time) VALUES (".db_quote($name).", ".db_quote($value).", now())";
 $sth=db_query($sql);

}

######################
function load_site_value($sys){

 $sql="select iname, ivalue from site_value where iname LIKE ".db_quote($sys.".%");
 $sth=db_query($sql);
 while ( list($iname, $ivalue)=mysql_fetch_row($sth) ){
       $GLOBALS[cut_prefix($iname, $sys)]=$ivalue;
 }

}

###################### util
function cut_prefix($str, $prefix){
 return preg_replace("/^".preg_quote($prefix)."\./i", "", $str);
}


?>
Return current item: PhpProjectMaster