Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 960017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:06:53+00:00 2026-05-16T01:06:53+00:00

Designer: tableName: designers actAs: I18n: fields: [name] columns: id: type: integer(2) unsigned: true primary:

  • 0

Designer:
tableName: designers
actAs:
I18n:
fields: [name]
columns:
id:
type: integer(2)
unsigned: true
primary: true
autoincrement: true
name:
type: string(30)
notnull: true

While default I18n behavior must be used like this

$d = Doctrine_Query::create()
                ->select('id, t.name')
                ->from('Designer d')
                ->leftJoin('d.Translation t')
                ->where("t.lang = 'en'")
                ->execute();

I would be faaar more convenient to set some constant to the current language, say en, and have every i18nable field correspond to it, thus having such query

$d = Doctrine_Query::create()
            ->select('id, name')
            ->from('Designer d')
            ->execute();

equivalent to the above one.

I’m trying to make a new behavior, extending the default one, which could provide such things, but I need your help.

Getting the needed language is easy, so let’s just say there is define('LANGUAGE', 'en'). The basic behavior class is

class TransparentI18N extends Doctrine_Template
{
    private $_translation = NULL;

    public function setUp()
    {
        $this->addListener(new TransparentI18NListener());

        $this->actAs(new Doctrine_Template_I18n($this->_options));
    }
}

So the idea is to add a listener, that would modify the query to set joins and select needed fields whenever such fields are present in the select clause. The TransparentI18NListener contains the preDqlSelect, which receives the Doctrine_Event object. And I can get the relevant Doctrine_Query and even getDqlPart('select') works, but the latter returns the raw select string, like id, t.name, how can I get, to which table each clause corresponds?

Then I’d have to set fields of the Doctrine_Record instance. Is it possible without making models extend some custom class which would give such functionality? I’m really reluctant to add such a class, but in case everything other fails, I should be able to make it save these fields and override the __get method to show translated fields if they are requested.

I was too scared to think about the insert/update/delete part, but hopefully if I deal with the above problems, I’d be able to add hooks to dql and get the job done.

Do you think such a think is possible in general without messing with core doctrine libraries? Having to use it in the default way would be a huge pain in the *…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:06:54+00:00Added an answer on May 16, 2026 at 1:06 am

    I don’t have a good, non-hacky solution for your actual problem but have an alternative to try.

    You could put all your find/get queries in the models corresponding table class.
    So you still have to do the Translation-Joints but all you queries are at one place and are easy to maintain.

    class DesignerTable extends Doctrine_Table
    {
        protected $_lang = LANGUAGE;
    
        public function findAll()
        {
            return Doctrine_Query::create()
                    ->select('id, t.name')
                    ->from('Designer d')
                    ->leftJoin('d.Translation t')
                    ->where("t.lang = ?", $this->_lang)
                    ->execute();
        }
    
        public function findOneById($id)
        {
            return Doctrine_Query::create()
                    ->select('id, t.name')
                    ->from('Designer d')
                    ->leftJoin('d.Translation t')
                    ->where('.lang = ?', $this->_lang)
                    ->andWhere('id = ?', $id) 
                    ->execute();
        }
        ...
    }
    
    // In your controllers:
    
    // Find all designers
    $designers = Doctrine_Core::getTable('Designer')->findAll();
    
    // Find one designer by id
    $designers = Doctrine_Core::getTable('Designer')->findOneById(13);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following yml configuration for Doctrine under MySQL: Designer: tableName: designers columns:
The designer want to make the company name in blue, but the company name
In Designer I set my grid name to equal MyGrid On clicking the button
My Designer.cs is as follows, namespace CeremonyApp { . . . [EdmEntityTypeAttribute(NamespaceName=CeremonyDBModel, Name=GuestParty)] [Serializable()]
my designer passed me a look that I would love to be able to
My web designer has provided me with updated fonts/icons that have been added to
I am a novice designer who could just use HTML to design my own
Using Share Point Designer 2010. I want to conduct client side validation (jquery) but
I am not the designer for these reports, so please bear with me for
based on .designer.cs, i infer that the menu's arrangement is based on the order

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.