M
M
Max Ba2018-04-24 11:54:34
PHP
Max Ba, 2018-04-24 11:54:34

Is the filtering method implemented correctly?

Guys, did I make the implementation of this class correctly. In particular, the filter() method. If the method is not called, then we display all the lines.

$invoice = new Invoice(DB::init());
$invoice->setUser(1);

$invoice->filter('company_name', 'ромашка');
$invoice->filter('company_inn', '123451234512');
$invoice->filter('email', '[email protected]');

$rows = $invoice->selectAll();
...

echo '<br>Всего найдено фирм: '.$invoice->count_rows();

company_name, company_inn, email, etc. - predefined variables inside the class

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2018-04-24
@Sanasol

There is no concept in the code of the concept of correctly or incorrectly self-written, if it is not quite trash or noodles.
Whether it works or not is the main criterion.
Like or dislike (for yourself) is the second most important criterion.

M
Maxim Timofeev, 2018-04-24
@webinar

And why not spy on popular solutions?
https://www.yiiframework.com/doc/guide/2.0/en/db-q...
As I understand it, yours ->filter('email', '[email protected]');can only build 1 type of query. And if you need like, <>, etc.? Will you create another method?
And I agree with Alexander Aksentiev , new Invoice(DB::init())this is very strange, you must admit it looks more beautifulInvoice::find()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question