How to use Query Class

How to use Query Class

mmarroquinmmarroquin Posts: 19Questions: 11Answers: 0
edited February 2015 in Free community support

First: DataTable is incredible and Editor more.

I'm working with Editor DataTable and I want to filter the first sql query (where the information shown for first time), check the query class documentation and modify the Database/Query.php:

Query Class

protected $_type = "Mysql";

public static function connect ( $user, $pass='', $host='', $port='', $db='', $dsn='' )
    {
        return false;
    }

public static function connect ( $user, $pass='mypass', $host='localhost', $port='', $db='mydb', $dsn='charset=utf8' )
    {
        return false;
    }

I need show the entries where FechaFacura is equal to 2014-07-01 (for example)

And in my Database/Database.php:

public function select ( $table, $field="*", $where=null, $orderBy=null )
     {
        return $this->query( 'select' )
            ->table( $table )
            ->get( $field )
            ->where('FechaFactura', '2014-07-01')
            ->order( $orderBy )
            ->exec();
     }

But nothing happens. I need to define my Database instance Contrstructor in another place?

Thanks in advance

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,684Questions: 1Answers: 10,498 Site admin
    Answer ✓

    Hi,

    Changing the select() method in the Database.php file probably isn't the best idea as it would mean that all queries that use select() would have that condition applied!

    Is this an Editor class that you want to filter? If so, I would suggest using the where() method. For example:

    $editor->where( 'FechaFactura', '2014-07-01' );
    

    Allan

  • mmarroquinmmarroquin Posts: 19Questions: 11Answers: 0
    edited February 2015

    Thanks for the reply Allan, I'll check.
    DataTable is incredible.
    :D

    I use a staff.php, I put in my example by my DataTable Edit:

    Editor::inst( $db, 'mknDetalleAseguradorasCopia' )
        ->fields(
            Field::inst('FechaFactura'),
            Field::inst('Vendedor'),
            Field::inst('FolioFiscal'),
            Field::inst('Documento'),
            Field::inst('ClaseDoc'),
            Field::inst( 'UsuarioCyc')
            )->where('FechaFactura', '2014-07-01')
        ->process( $_POST )
        ->json();
    

    Thanks Allan, you so Big :D

This discussion has been closed.