PHP doctrine relationship with namespaces

I just started using PHP namespaces. I have two classes of models in separate files

In both files, I declare the namespace first

namespace eu \ ed \ sixImport \ importViewer \ models;

first grade:

class Log extends \ Doctrine_Record

    $this->hasMany('eu\ed\sixImport\importViewer\models\DataSource as DataSource', array(
        'local' => 'id',
        'foreign' => 'logId'));//setup relationship in setUp method

second class:

class DataSource extends \ Doctrine_Record

    $this->hasOne('eu\ed\sixImport\importViewer\models\Log as Log', array(
        'local' => 'logId',
        'foreign' => 'id'));//setup relationship in setUp method

Everything works fine until I do something like this

    $query = \Doctrine_Query::create()
        ->select('log.*')
        ->from('eu\ed\sixImport\importViewer\models\Log log')
        ->leftJoin("log.DataSource")
        ->orderBy("log.id DESC");

    $requiredPage = (($startingRow - ($startingRow%$rowsRequired))/$rowsRequired) + 1;
    $pager = new \Doctrine_Pager($query, $requiredPage, $rowsRequired);
    $res = $pager->execute();        
    $this->logsPageCount = $pager->getNumResults();
    print_r($res[0]["DataSource"]->toArray());//it fails on access to relationship

Than the doctrine throws an Uncaught exception "Doctrine_Exception" with the message "Could not find the eu \ ed class" in C: \ wamp \ www \ importViewer \ resources \ doctrine \ Doctrine-1.1.5 \ lib \ Doctrine \ Table.php: 293. ..

Exception , 'eu\ed'. [s] , . , ?

+3
1

, Doctrine 1 . Doctrine 2 - ( API Java Hibernate) ​​, Doctrine 1.

0

Source: https://habr.com/ru/post/1723993/


All Articles