I’m getting an error in WordPress when I’m try to include a class

I’ve to do a search form into my WordPress into a specific table in the database. So, I create a DAO class where I make the query and I save the result into a DTO class. To do that, I create an abstract class where I make the conection to my database and then made the query. Something like this:

abstract class abstract_dao {
    protected $conectorbd;

    function __construct() {
        $this->conectorbd = new conectorbd();

Where I make the conection, and then I’ve the cancion_dao.php, something like this:

define('RUTA', get_bloginfo('template_directory') . "/");
require_once 'abstract_dao.php';
require_once '../db/dto/cancion_dto.php';

class cancion_dao extends abstract_dao {

    function __construct() {

    function getCanciones($consulta) {

        $sql = "SELECT * FROM canciones WHERE trackName LIKE '%" . $this->conectorbd->escapar_cadena($consulta) . "%'";          

        $vuelta = $this->conectorbd->ejecutar_query($sql);
        $dto = null;
        while ($datos = $this->conectorbd->bd_fetch_array($vuelta)) {                
            $dto = new cancion_dto($datos['id'], $datos['trackName'], $datos['artistName'], $datos['albumName'], $datos['category']);
        return $dto;


I know it’s not 100% correct. But for my question I think it’s enough. For more information I have abstract_dao and cancion_dao in the same directory. I have this:


So, all of this information is to clarify my situation. And this is the problem:

When I try to search something and I call to my function getCanciones() I get this error:

require_once(/db/dto/cancion_dto.php): failed to open stream: No such file or directory on line 4.

Then, I try with the full URL with:

define('RUTA', get_bloginfo('template_directory') . "/");

And I’ve this new message error:

require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0

I try with other options like using $_SERVER['DOCUMENT_ROOT'], dirname( __FILE__ ), etc. But the only that I get are messages error.

I don’t know how to resolve this and I hope someone can help. How can I include files which aren’t in the same directory?

Thank you and sorry about my english skills!

Source: wordpress

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.