Search code examples
phpsymfonygenesys

What is the best way of using information from another database using symfony


I have a management application being build in Symfony, I require to fetch information from other application, Genesys which is an enterprise software to handle various types of communications from phone to online chat help, the database for Genesys historical data is object oriented and easy to use, but I wonder what would be the best way to interact with it, my Symfony project already has the connection set up, however I am not certain if I should just get information using queries or to create and map objects according to Genesys design, and an SDK or library is out of the question since Genesys only provides such software for Java and Microsoft .Net.


config.yml

# Doctrine Configuration
doctrine:
    dbal:
         default_connection: cscc
        connections:
            cscc:
                driver:   pdo_mysql
                host:     "%database_host%"
                port:     "%database_port%"
                dbname:   "%database_name%"
                user:     "%database_user%"
                password: "%database_password%"
                charset:  UTF8                
            infomart:
                driver:   pdo_sqlsrv
                host:     '%database_host2%'
                port:     '%database_port2%'
                dbname:   '%database_name2%'
                user:     '%database_user2%'
                password: '%database_password2%'
                charset:  UTF8       
             wfm:
                driver:   pdo_sqlsrv
                host:     '%database_host3%'
                port:     '%database_port3%'
                dbname:   '%database_name3%'
                user:     '%database_user3%'
                password: '%database_password3%'
                charset:  UTF8 

Consider the following: the type of queries I'll be required to use in a pure sql approach are kind of complicated, and long

Select DISTINCT INTERACTION_FACT_GI2.START_TS_TIME as cal_date
,RESOURCE_GI2.EMPLOYEE_ID as Windows_User
,RESOURCE_GI2.RESOURCE_NAME Ignition_ID
,RESOURCE_GI2.AGENT_FIRST_NAME
,RESOURCE_GI2.AGENT_LAST_NAME
,INTERACTION_FACT_GI2.SOURCE_ADDRESS as Phone
,INTERACTION_FACT_GI2.TARGET_ADDRESS
,TicketType
,AgentComment
,ItemCategory
,Problem
,Solution
,storeID
,LoyaltyNumber
,OrderNumber
 FROM [IRF_USER_DATA_CUST_1] 
 JOIN INTERACTION_RESOURCE_FACT_GI2 ON      (INTERACTION_RESOURCE_FACT_GI2.INTERACTION_RESOURCE_ID=IRF_USER_DATA_CUST_1.INTERACTION_RESOURCE_ID)
  JOIN INTERACTION_FACT_GI2 on (INTERACTION_FACT_GI2.INTERACTION_ID=INTERACTION_RESOURCE_FACT_GI2.INTERACTION_ID)
  JOIN DATE_TIME ON (DATE_TIME.DATE_TIME_KEY=INTERACTION_FACT_GI2.START_DATE_TIME_KEY)
  JOIN MEDIA_TYPE ON (MEDIA_TYPE.MEDIA_TYPE_KEY=INTERACTION_RESOURCE_FACT_GI2.MEDIA_TYPE_KEY)
  JOIN RESOURCE_GI2 ON (INTERACTION_RESOURCE_FACT_GI2.RESOURCE_KEY=RESOURCE_GI2.RESOURCE_KEY)
  JOIN [INTERACTION_TYPE] ON [INTERACTION_TYPE].[INTERACTION_TYPE_KEY] = INTERACTION_FACT_GI2.INTERACTION_TYPE_KEY

 Where [IRF_USER_DATA_CUST_1].TICKETTYPE =''
  AND [IRF_USER_DATA_CUST_1].TICKETTYPE IS NOT NULL
  AND MEDIA_TYPE.MEDIA_NAME IN ('Voice','Email')
  AND [INTERACTION_TYPE].INTERACTION_TYPE= 'Inbound'
  AND INTERACTION_FACT_GI2.START_TS_TIME  > '2017-01-26 00:00:00' and  INTERACTION_FACT_GI2.START_TS_TIME < '2017-01-27 23:59:59'

  order by INTERACTION_FACT_GI2.START_TS_TIME

Solution

  • You should definitely create and map objects to Genesys database. Generally, you want to push away vendor (Genesys in this case) related syntax and interactions away from the website business code.

    To do this, create a UserRepository (and other repositories, depending on what objects you manage), which internally uses GenesysClient. In GenesysClient you can write the Genesys specific queries.

    This way your code is decoupled from Genesys, is more readable, necessary changes can be made inside GenesysClient if needed.