PHP code example of jeidison / native-query

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

    

jeidison / native-query example snippets


return [
    'path-sql' => database_path('native-query'),
    'type' => Jeidison\NativeQuery\Enums\FileType::PHP,
];

CONST findTab1 = "
SELECT * FROM TAB1 WHERE PAR1 = :par1
";

...

class ModelX extends Model
{
    use HasNativeQuery;
    
    protected $queryFile = '/path/file-with-queries';

    ...
}

ModelX::nativeQuery('findTab1')->param('par1', 'value1')->param('par2', 'value2')->exec();

ModelX::nativeQuery('findTab1')->param(['par1' => 'value1'])->exec();

ModelX::nativeQuery('findTab1')->param(['par1' => 'value1'])->->debug();

NativeQuery::query('findTab1')
            ->queryFile('/path/file-with-queries')
            ->param('par1', 'value1')
            ->exec();
bash
$ php artisan vendor:publish --provider="Jeidison\NativeQuery\Provider\NativeQueryServiceProvider"
xml
<query name="findTab1">
    SELECT * FROM TAB1 WHERE PAR1 = ?
</query>