PHP code example of legiaifenix / databasegate

1. Go to this page and download the library: Download legiaifenix/databasegate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

legiaifenix / databasegate example snippets


    public function reallyNeedToSortThis(DatabaseService $databaseService)
    {
        return $databaseService->getEntriesOfTableWithConditions($yourDesiredTable, $yourConditions);
    }

    $conditions = [
        'count' => '*'
    ];

    $results = $databaseGate->getEntriesOfTableWithConditions('products', $conditions);

    $conditions = [
        'select' => [
            ['clients.name'],
            ['clients.email'],
            ['products.*']
        ],
        'join' => [
            'products' => ['products.client_id', '=', 'clients.id']
        ]
    ];

    $results = $databaseGate->getEntriesOfTableWithConditions('clients', $conditions);

    $conditions = [
            'select' => [
                ['clients.name'],
                ['clients.email'],
                ['products.*']
            ],
            'leftJoin' => [
                'products' => ['products.client_id', '=', 'clients.id']
            ]
        ];
    
        $results = $databaseGate->getEntriesOfTableWithConditions('clients', $conditions);

    $conditions = [
        ...
        'paginate' => '5'
    ];

    $results = $databaseGate->getEntriesOfTableWithConditions('clients', $conditions);

    $conditions = [
        'where' => [
            ['products.visible', '=', '1']
        ]
    ];

    $results = $databaseGate->getEntriesOfTableWithConditions('products', $conditions);

    Client Email: {{$results->email}}
    Total Cost: {{$results->totalCost}}

    $conditions = [
                'join' => [
                    'clients' => ['clients.id', '=', 'products.client_id']
                ],
                'where' => [
                    ['clients.email', '=', '[email protected]']
                ],
                'whereBetween' => [
                    'price' => ['30', '70']
                ],
                'sum' => 'products.price'
            ];

        $results = $databaseGate->getEntriesOfTableWithConditions('products', $conditions);


    $results = $this->databaseGate->getEntriesOfTableWithConditions('colors', $conditions, true);
    var_dump($results);

    $id = $this->databaseGate->getEntriesOfTableWithConditions('<table name>', $conditions);
    var_dump($results);