Ok, following from my previous thread (now resolved) i want to convert and use namespace.
headScript.php:
<?php
class headScript
{
public function connection()
{
try
{
$dbh = new PDO("mysql:host=localhost;dbname=roundth4_rtb2", 'root', ''); // Dev
return $dbh;
}
catch(PDOException $e)
{
echo "Error :- " . $e->getMessage();
die();
}
}
public function headLoad()
{
$cxn = $this->connection()->prepare("SELECT scriptCode FROM head_scripts WHERE active != '0'");
$cxn->execute();
$cxn->setFetchMode(PDO::FETCH_ASSOC);
while($row = $cxn->fetch())
{
print "<script>";
print $row['scriptCode'];
print "</script>";
}
}
}
?>
I'd like to remove the connection function and put this in its own file, then using namespace to pull this in. That way i have one file which can be called via namespace and i can use this function.
Am I thinking this is possible when it is not?
I have tried a few things but cant seem to get it to work.
Can anyone offer assistance?