針對wordpress寫opion函數utility.php

針對wordpress寫opion函數utility.php(查看次數:984)

回首頁

2012-01-04 10:36:12
[xml]
<?
function get_post_option($id,$key)
{
global $conn;
$sSQL="select meta_value from `wp_postmeta` where post_id='$id' and meta_key='$key'";
$result=mysql_query($sSQL,$conn);
//echo $sSQL;
$row=@mysql_fetch_object($result);
if($row==null)
return "";
else
return $row->meta_value;

}

function update_post_option($id,$key,$value)
{
global $conn;
$sSQL="select meta_value from `wp_postmeta` where post_id='$id' and meta_key='$key'";

$result=mysql_query($sSQL,$conn);
$row=mysql_fetch_object($result);
if($row==null)
$sSQL="insert into `wp_postmeta` (post_id,meta_key,meta_value) values('".$id."','".$key."','".$value."')";
else
$sSQL="update `wp_postmeta` set meta_value='$value' where post_id='$id' and meta_key='$key' ";
//echo $sSQL;
$result=mysql_query($sSQL,$conn);
if($result==true)
return "";
else
return $sSQL;
}

function get_option($id,$key)
{
global $conn;
$sSQL="select option_value from `wp_options` where blog_id='$id' and option_name='$key'";
$result=mysql_query($sSQL,$conn);
//echo $sSQL;
$row=@mysql_fetch_object($result);
if($row==null)
return "";
else
return $row->option_value;

}

function update_option($id,$key,$value)
{
global $conn;
$sSQL="select option_value from `wp_options` where blog_id='$id' and option_name='$key'";

$result=mysql_query($sSQL,$conn);
$row=mysql_fetch_object($result);
if($row==null)
$sSQL="insert into `wp_options` (blog_id,option_name,option_value) values('".$id."','".$key."','".$value."')";
else
$sSQL="update `wp_options` set option_value='$value' where blog_id='$id' and option_name='$key' ";
//echo $sSQL;
$result=mysql_query($sSQL,$conn);
if($result==true)
return "";
else
return $sSQL;
}
?>
[/xml]

針對wordpress寫opion函數utility.php
上一篇:php登入範例login.php(2843)      下一篇:wc_admin_unsnooze_admin_notes(0)