Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/Ecombricks/Framework/Model/ResourceModel/Db/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/Ecombricks/Framework/Model/ResourceModel/Db/ConnectionProvider.php
<?php
/**
 * Copyright © eComBricks. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Ecombricks\Framework\Model\ResourceModel\Db;

/**
 * Resource connection provider
 */
class ConnectionProvider
{
    
    /**
     * Resource connection
     * 
     * @var \Magento\Framework\App\ResourceConnection
     */
    protected $resourceConnection;
    
    /**
     * Resource name
     * 
     * @var string
     */
    protected $resourceName;
    
    /**
     * Connection
     * 
     * @var \Magento\Framework\DB\Adapter\AdapterInterface
     */
    protected $connection;
    
    /**
     * Constructor
     * 
     * @param \Magento\Framework\App\ResourceConnection $resourceConnection
     * @param string $resourceName
     * @return void
     */
    public function __construct(
        \Magento\Framework\App\ResourceConnection $resourceConnection,
        string $resourceName = \Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION
    )
    {
        $this->resourceConnection = $resourceConnection;
        $this->resourceName = $resourceName;
    }
    
    /**
     * Get connection
     * 
     * @return \Magento\Framework\DB\Adapter\AdapterInterface
     */
    public function getConnection(): \Magento\Framework\DB\Adapter\AdapterInterface
    {
        if ($this->connection === null) {
            $this->connection = $this->resourceConnection->getConnection($this->resourceName);
        }
        return $this->connection;
    }
    
    /**
     * Get select
     * 
     * @return \Magento\Framework\DB\Select
     */
    public function getSelect(): \Magento\Framework\DB\Select
    {
        return $this->getConnection()->select();
    }
    
    /**
     * Get table
     * 
     * @param string $tableName
     * @return string
     */
    public function getTable(string $tableName): string
    {
        return $this->resourceConnection->getTableName($tableName, $this->resourceName);
    }
    
    /**
     * Get condition
     * 
     * @param array $subConditions
     * @param string $joinOperator
     * @return string
     */
    public function getCondition(array $subConditions, string $joinOperator = 'AND'): string
    {
        return '('.join(') '.$joinOperator.' (', $subConditions).')';
    }
    
}

Spamworldpro Mini