Skip to content

virgiliopontes/autowheremysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto Where MySQL for PHP

This package to create the where part of your MySQL queries from a simple form submission, and everything automatically.

Install

composer require virgiliopontes/autowheremysql

Examples

The Hello World example.

Go to the examples directory in the root of the repository (vendor/virgiliopontes/autowheremysql/examples).

Open the index.php with your favorite text editor and take a look at the source code.

Open the browser

Navigate to the directory where the index.php is allocated.

Exemple

http://127.0.0.1/vendor/virgiliopontes/autowheremysql/

Note: You need to replace 127.0.0.1 with the machine address where the example is

Installation

Composer

Install Composer if you don't have it.

composer require virgiliopontes/autowheremysql

Or in your composer.json file add:

{
    "require": {
		"virgiliopontes/autowheremysql": "~2",
    }
}

And the just run:

composer update

and thats it.

Using

Uses in Controller by adding use AutoWhere/AutoWhereMysql after namespace

<?php
namespace App\Controllers;

use AutoWhere\AutoWhereMysql; //<--- Here

class YourClass
{
	//...

    public function YourMethod()
    {        
        $autoWhereMysql = new AutoWhere\AutoWhereMysql();
        if(isset($_POST['campofiltro'])){
            $where = $autoWhereMysql->make_where($_POST['campofiltro'],$_POST['operador'],$_POST['valorfiltro']);
            echo $where;
        }

    }
}    

Questions?

Call me on Twitter @virgiliopontes.

License

MIT