PHP code example of mphpmaster / model-query-selector

1. Go to this page and download the library: Download mphpmaster/model-query-selector 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/ */

    

mphpmaster / model-query-selector example snippets


use MPhpMaster\ModelQuerySelector\ModelQuerySelector;

// Usage example
$querySelector = mqs(User::class, 'u');
dump($querySelector); // Outputs: "users as u"

use MPhpMaster\ModelQuerySelector\ModelQuerySelector;
use App\Models\User;

// Static method call to qc()
$querySelector = ModelQuerySelector::qc(['column1', 'column2'], User::class);
dump($querySelector); // Outputs: "users.column1, users.column2"

// Static method call to table()
$querySelector = ModelQuerySelector::table(User::class, 'alias');
dump($querySelector); // Outputs: "users as alias"

// Dynamic method call to table()
$querySelector = new ModelQuerySelector();
$querySelector->table(User::class, 'alias');
dump($querySelector); // Outputs: "users as alias"

// Dynamic method call to qc()
$querySelector = new ModelQuerySelector(User::class);
$querySelector->qc(['column1', 'column2'], 'alias');
dump($querySelector); // Outputs: "alias.column1, alias.column2"

use MPhpMaster\ModelQuerySelector\ModelQuerySelector;

$querySelector = mqs(User::class, 'u');
echo $querySelector->toString(); // Outputs: "users as u". same as: `echo trim($querySelector);`