Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sqlquerymanager Laravel Package

beeflow/sqlquerymanager

Simple SQL query manager for PHP/Symfony. Load SQL from files and safely inject parameters using typed placeholders (string, int, secureString, email, etc.), with support for custom vartypes via service tags. Use as a Symfony service or via the SQLQuery class.

View on GitHub
Deep Wiki
Context7

Simple SQL query manager

A simple SQL query manager with option to secure queries by setting parameter type.

It uses classes which represents siple var types as string, integer etc... and own classes like secureString, email etc...

To better secure queries, you can create your own var types classes, for example password or phone

Install

composer

$ composer require "beeflow/sqlquerymanager:dev-master"

GIT

$ git clone https://github/beeflow/

and then add to app/AppKernel.php

public function registerBundles()
{
    ...
    new Beeflow\SQLQueryManager\SQLQueryBundle(),
}

To add new Vartype just insert into your services.yml

app.YourVarType:
    class: YourBundle\Lib\Vartypes\YourVarType;
    tags:
        - { name: beeflow.sql_manager.vartype, alias: yourVarTypeAlias }

and now you can use it in SQL query:

SELECT example1 FROM exampleTable WHERE example = {value->yourVarTypeAlias}

Examples

SQL query example:

SELECT example1 FROM exampleTable WHERE example = {value->secureString}

Using SQLQueryManager as Symfony service

In your Controller:

$sqlManager = $this->get('beeflow.sql_query_manager');

Set default directory with SQL files

$slqlManager->setSqlDirectory('sql_directory');

Use query as a method with temporary different directory with SQL files:

$slqlManager->sqlExample([
      'value'                  => 'TEST_VALUE',
      'value2'                 => 11,
      'vatno'                  => '1111111111',
      'valueArrayWithoutAtype' => array('one', 'two', 'tree')
], 'someTmpDirectory');

Example with new method of calling SQL files

`<?php

	use Beeflow\SQLQueryManager\SQLQuery

	try {
	    $query = new SQLQuery();
        $query->sqlExample([
                'value'                  => 'TEST_VALUE',
                'value2'                 => 11,
                'vatno'                  => '1111111111',
                'valueArrayWithoutAtype' => array('one', 'two', 'tree')
        ]);
         
        echo $query->getQuery();
	} catch (Exception $ex) {
        echo $ex->getMessage();
	}`

Example with a correct data:

`<?php

use Beeflow\SQLQueryManager\SQLQuery

try {
    $query = new SQLQuery("sqlExample");
    $query->value = 'TEST_VALUE';

    // if you set a string value it will be set as 0 (zero) because (integer)'ddd' = 0 (zero)
    $query->value2 = 11;

    // polish vat no algoritm allows to use 1111111111 vat number
    // if you want to check an european vat no see:
    // http://www.phpclasses.org/package/2280-PHP-Check-if-a-European-VAT-number-is-valid.html
    $query->vatno = '1111111111';

    $query->valueArrayWithoutAtype = array('one', 'two', 'tree');
    $query->valueWithoutParamType = "value Without Param Type";

    echo $query->getQuery();
} catch (Exception $ex) {
    echo $ex->getMessage();
}`

Example with incorrect data:

`<?php

use Beeflow\SQLQueryManager\SQLQuery

try {
    $newQuery = new SQLQuery("sqlExample");
    $newQuery->value = 'TEST_VALUE';
    $newQuery->value2 = 11;

    // incorrect polish vat no
    $newQuery->vatno = '1212111211';

    $query->valueArrayWithoutAtype = array('one', 'two', 'tree');
    $query->valueWithoutParamType = "value Without Param Type";
    echo $newQuery->getQuery();
} catch (Exception $ex) {
    echo $ex->getMessage();
}`

Example with conditioned value:

`<?php

use Beeflow\SQLQueryManager\SQLQuery

try {
    $query = new SQLQuery("sqlExample");
    $query->value = 'TEST_VALUE';

    // if you set a string value it will be set as 0 (zero) because (integer)'ddd' = 0 (zero)
    $query->value2 = 11;
    $query->vatno = '1111111111';

    $query->valueArrayWithoutAtype = array('one', 'two', 'tree');
    $query->valueWithoutParamType = "value Without Param Type";

    // condition !empty()
    $query->notEmptyValue = 1;

    echo $query->getQuery();
} catch (Exception $ex) {
    echo $ex->getMessage();
}`
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
anousss007/vigilance
supportpal/eloquent-model
ardenexal/fhir-models
laravel-at/laravel-image-sanitize
romalytar/yammi-audit-log-laravel
ardenexal/fhir-validation
arshaviras/weather-widget
laravel-chronicle/core
sunchayn/nimbus
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon