2017 © Pedro Peláez
 

library phalcon-searcher

Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.

image

stanislav-web/phalcon-searcher

Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.

  • Tuesday, February 10, 2015
  • by stanislav-web
  • Repository
  • 8 Watchers
  • 25 Stars
  • 161 Installations
  • JavaScript
  • 1 Dependents
  • 5 Suggesters
  • 6 Forks
  • 5 Open issues
  • 9 Versions
  • 5 % Grown

The README.md

Phalcon Database Searcher

Scrutinizer Code Quality Code Coverage Build Status Total Downloads Latest Unstable Version, (*1)

Extension is used to group search for project models. (Currently under TDD), (*2)

Description

This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site., (*3)

Change Log

[v 1.0-beta] 2014-12-16

- support MySQL
- support column type such as INT, VARCHAR, CHAR, TEXT, DATE, DATETIME
- fulltext search
- support all main expressions (where, order, group, limit, offset)
- multi table search
- compatible with \Phalcon\Paginator
- view results as json, serialized, array or \Phalcon\Mvc\Model\Resultset\Simple
- support callbacks to pretty modifying result

Compatible

  • PSR-0, PSR-1, PSR-2, PSR-4 Standards

System requirements

  • PHP 5.5.x >
  • MySQL
  • Phalcon extension 1.3.x

Install

First update your dependencies through composer. Add to your composer.json:, (*4)

"require": {
    "stanislav-web/phalcon-searcher": "dev-master",
}

Then run to update dependency and autoloader, (*5)

php composer.phar update
php composer.phar install

or just, (*6)

php composer.phar require stanislav-web/phalcon-searcher dev-master 

(Do not forget to include the composer autoloader), (*7)

Or manual require in your loader service, (*8)

    $loader->registerNamespaces([
        'Searcher\Searcher' => 'path to src'
    ]);

You can create an injectable service, (*9)

    $this->di['searcher'] = function() {
        return new \Searcher\Searcher();
    };

Usage

Simple usage

<?php 
    use \Searcher\Searcher;

    // create object instance
    $searcher = new Searcher();

    // Prepare models and fields to participate in search
    $searcher->setFields([
        '\Models\Auto'    =>    [
            'mark',
            'model'
        ],
        '\Models\Distributor'    =>    [
            'name',
            'description'
        ]
    ])
    ->setQuery('FerRari');

    $result = $searcher->run();

Filters

<?php 
    use \Searcher\Searcher;

    // create object instance
    $searcher = new Searcher();

    // Prepare models and fields to participate in search
    $searcher->setFields([
        '\Models\Auto'    =>    [
            'mark',
            'model'
        ],
        '\Models\Distributor'    =>    [
            'name',
            'description'
        ]
    ])
    ->setMin(3)                                         //  minimum char to query
    ->setMax(15)                                        //  maximum char to query
    ->setExact(true)                                    //  strict mode search 
    ->setOrder(['\Models\Auto' => ['id' => 'DESC']])    //  ORDER BY \Models\Auto.id DESC
    ->setGroup(['\Models\Distributor' => ['id']])       //  GROUP BY \Models\Auto.id
    ->setThreshold(100)                                 //  LIMIT 100
    ->setQuery('FerRari');

    $result = $searcher->run();

<?php 
    use \Searcher\Searcher;

    // create object instance
    $searcher = new Searcher();

    // Prepare models and fields to participate in search
    $searcher->setFields([
        '\Models\Auto'    =>    [
            'mark',
            'model'
        ],
        '\Models\Distributor'    =>    [
            'name',
            'description'
        ]
    ])
    ->setExact(true) // strict mode search 
    ->setOrder([
                    '\Models\Auto' => ['id' => 'DESC']
                    '\Models\Distributor' => ['description' =>  'ASC']
              ])                                                //  ORDER BY \Models\Auto.id DESC, \Models\Distributor.description ASC
    ->setGroup([
                '\Models\Auto' => ['id', 'mark']
                '\Models\Distributor' => ['id', 'description']
              ])                                                //  GROUP BY \Models\Auto.id, \Models\Auto.mark, \Models\Distributor.id, \Models\Distributor.description 

    ->setThreshold([0,100])                                     //    OFFSET 0, LIMIT 100
    ->setQuery('FerRari');

    $result = $searcher->run();

Result modifiers and callbacks

<?php 
    use \Searcher\Searcher;

    // create object instance
    $searcher = new Searcher();

    // Prepare models and fields to participate in search
    $searcher->setFields([
        '\Models\Auto'    =>    [
            'mark',
            'model'
        ],
        '\Models\Distributor'    =>    [
            'name',
            'description'
        ]
    ])
    ->setQuery('FerRari');

    $result = $searcher->run('json'); // available array, serialize, json, Resultset as default

    // OR

    /**
     * @param $result 
     */
    $result = $searcher->run('array', function($result) {

        //... any modifiers 
        return $result;

    }); // available, array, serialize, json, Resultset as default

Unit Test

Also available in /phpunit directory. Run command to start, (*10)

php build/phpunit.phar --configuration phpunit.xml.dist --coverage-text

Read logs from phpunit/log, (*11)

Change Log

Issues

Screen (For what I use it?)

Alt text, (*12)

Project Status MIT License ![Gitter](https://badges.gitter.im/Join Chat.svg), (*13)

SensioLabsInsight, (*14)

The Versions

10/02 2015

dev-master

9999999-dev https://github.com/stanislav-web/Searcher

Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

phalcon phalcon search phalcon searcher

04/01 2015

dev-scrutinizer-patch-7

dev-scrutinizer-patch-7 https://github.com/stanislav-web/Searcher

Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

phalcon phalcon search phalcon searcher

29/12 2014

dev-scrutinizer-patch-6

dev-scrutinizer-patch-6 https://github.com/stanislav-web/Searcher

Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

phalcon phalcon search phalcon searcher

19/12 2014

dev-scrutinizer-patch-5

dev-scrutinizer-patch-5 https://github.com/stanislav-web/Searcher

Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

phalcon phalcon search phalcon searcher

17/12 2014

v1.0-beta

1.0.0.0-beta https://github.com/stanislav-web/Searcher

Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

phalcon phalcon search phalcon searcher

17/12 2014

dev-scrutinizer-patch-4

dev-scrutinizer-patch-4 https://github.com/stanislav-web/Searcher

Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

phalcon phalcon search phalcon searcher

17/12 2014

dev-scrutinizer-patch-3

dev-scrutinizer-patch-3 https://github.com/stanislav-web/Searcher

Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

phalcon phalcon search phalcon searcher

17/12 2014

dev-scrutinizer-patch-2

dev-scrutinizer-patch-2 https://github.com/stanislav-web/Searcher

Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

phalcon phalcon search phalcon searcher

17/12 2014

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1 https://github.com/stanislav-web/Searcher

Phalcon Database Searcher. This is the search service is designed to search multiple SQL tables. Convenient to use autocomplete, search documents, search the whole site.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

phalcon phalcon search phalcon searcher