如何调用不同目录中的PHP函数并获得结果? [英] How to call a PHP function which is in Different Directory and get the results?

查看:67
本文介绍了如何调用不同目录中的PHP函数并获得结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

htdocs(root)-Myproject/data access/da_admin.php


$base = $_SERVER['DOCUMENT_ROOT'];
include_once($base.DIRECTORY_SEPARATOR.'status_codes.php');
include_once($base.DIRECTORY_SEPARATOR.'data-access'.DIRECTORY_SEPARATOR.'connection.php');

function db_get_client_master_list($active)
{
	// Base Query
	$client_squery_base = "select * from client_master";
	
	// Where query
	$client_squery_where = "";
	
	// Data
	$client_sdata = array();
	
	$filter_count = 0;

	if($active != "")
	{
		if($filter_count == 0)
		{
			// Query
			$client_squery_where = $client_squery_where." where client_active=:active";								
		}
		else
		{
			// Query
			$client_squery_where = $client_squery_where." and client_active=:active";				
		}
		
		// Data
		$client_sdata[':active']  = $active;
		
		$filter_count++;
	}
	
	$client_squery = $client_squery_base.$client_squery_where;
	
	try
	{
		$dbConnection = get_conn_handle();
		
		$client_sstatement = $dbConnection->prepare($client_squery);
		
		$client_sstatement -> execute($client_sdata);
		
		$client_sdetails = $client_sstatement -> fetchAll();
		
		if(FALSE === $client_sdetails)
		{
			$return["status"] = FAILURE;
			$return["data"]   = "";
		}
		else if(count($client_sdetails) <= 0)
		{
			$return["status"] = DB_NO_RECORD;
			$return["data"]   = "";
		}
		else
		{
			$return["status"] = DB_RECORD_ALREADY_EXISTS;
			$return["data"]   = $client_sdetails;
		}
	}
	catch(PDOException $e)
	{
		// Log the error
		$return["status"] = FAILURE;
		$return["data"] = $e->getMessage();
	}
	
	return $return;
}
?>

I want to call this function inside Myproject.How can I Do this?Please help me?

推荐答案

base =


_SERVER ['DOCUMENT_ROOT'];
include_once(
_SERVER['DOCUMENT_ROOT']; include_once(


base.DIRECTORY_SEPARATOR.'status_codes.php');
include_once(
base.DIRECTORY_SEPARATOR.'status_codes.php'); include_once(


这篇关于如何调用不同目录中的PHP函数并获得结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆