Sup! We have core class with mysql connection, than we include plugin and we need that plugin cant access to our DB without core class methods.
index.php
<?php
class Core
{
function connect()
{
$db = @mysql_connect($host, $user, $pass);
@mysql_select_db($base, $db);
}
function query($sql)
{
return mysql_query($sql);
}
}
global $c;
$c = new Core();
include( plugin.php );
$p = new Plugin();
echo $p->not_work_connection();
echo $p->work_connection();
?>
plugin.php
<?php
class Plugin
{
function not_work_connection()
{
$sql = SELECT * FROM `net_country` LIMIT 0 , 1 ;
$result = mysql_query($sql);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
return print_r($row, 1);
}
}
function work_connection()
{
global $c;
$result =$c->query( SELECT * FROM `net_country` LIMIT 0 , 1 );
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
return print_r($row, 1);
}
}
}
?>
我需要限制使用包括文字的出入,但假日可以使用核心方法进行查询。 如何做到这一点?