Hi all.

I recently set up dual boot Os (7, and Ubuntu 12.10).

The namespace call was/is working on the Windows 7 env (same version of XAMPP).

I know Linux is case sensitive so i have amended the file/folder calls.

Although the file exists, i am getting:

Message: Class classLib\dataBase\database_Connection could not be loaded

DB Class:

<?php
// root -> /classLib/dataBase/database_Connection.php:

namespace classLib\dataBase; // declare namespcae

class database_Connection {
/**
* @var PDO The database link.
*/

    protected static $dbLink;

    /**
    * Returns an open PDO object. This object will be shared
    * among all who call this method, so that you don't have
    * to be creating multiple connections to MySQL in the
    * same request.
    * @return PDO
    */

    public static function get()
    {
        if(self::$dbLink == null)
        {
            $dns = 'mysql:host=localhost;dbname=rtbClass'; //dev db
            self::$dbLink = new \PDO($dns, 'root', ''); //dev usage only as root
            self::$dbLink->exec("SET NAMES 'utf8'");
            self::$dbLink->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        }
        return self::$dbLink;
    }

    /*
    * We don't want this class to be able to spawn objects.
    * By making these two methods private, we effectively
    * prevent that from happening.
    */

    private function __construct() {
        return false;
    }

    private function __clone() {
        return self::get();
    }

}
?>

This is being called by a class that loads active Jquery/Java etc:

<?php
// root: -> /classLib/load/load_headScript.php :
spl_autoload_extensions(".php");
spl_autoload_register();

use classLib\dataBase\database_Connection as DB; // import namespace for code reuse

class load_headScript
{

    public function headLoad()
    {
        $sql = "SELECT scriptCode, scriptName FROM j_scripts WHERE active != '0'";
        $stmt = DB::get()->prepare($sql);
        $stmt->execute();
        $stmt->setFetchMode(\PDO::FETCH_ASSOC);

        while($rowHead = $stmt->fetch())
        {
            print '<script type="text/javascript" name='.$rowHead['scriptName'].'>';
            print $rowHead['scriptCode'];
            print '</script>';
        }
    }

}
?>

This is the calling:

<?php

    include 'classLib/includeOnly.php';

        try 
        {
            $t1 = new load_headScript;
            print  $t1->headLoad();
        }
        catch(Exception $e)
        {
            echo 'Message: ' .$e->getMessage();
        }

?>

the above include is to the php file that holds the Jquery/Java calling.

Am i over looking something, or is there a config that has to be set up under Linux XAMPP but not W7?

edit: I have tried with and withoput the following:

spl_autoload_extensions(".php");
spl_autoload_register();

Recommended Answers

All 2 Replies

Member Avatar for LastMitch

@Squidge

Since you are trying to setup the namespaces through php. Try the other way, it's kinda like a shortcut but it would be quick. After that you can figure out how to setup namespace through php.

http://lxc.sourceforge.net/index.php/about/kernel-namespaces/network/configuration/

... Thanks for the link!

I'm still reading it and trying to understand and playing around with the functions.

It gonna take me a few days or more to practice it.

@LastMitch
Many thanks, alas the link is for IT infrastructure Namespacing.

I shall keep digging and report back

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.