Closed 13ran closed 5 months ago
I'm checking.
I think I made it on purpose since it is not recommended to use dash in the columns. Using dashes (-) in column names is generally discouraged because many programming languages, databases, and tools interpret the dash as a subtraction operator or other special character.
you can use underscore instead.
If the column name has `` around it, it shouldn't cause any problems. I'd really like to avoid renaming all the columns in my database as it already has millions of rows and selecting as another name causes issues when I try and filter the column
what about using like this:
$dt->query("SELECT
`test-test` AS `test_test`
FROM
`test`");
In this case, you dont have to rename your columns.
Causes issues with filtering as test_test
doesnt exist in the database. Unless theres some way I can change the column?
$dt->filter('test_test', function () {
return $this->column = '`test-test`';
});
That doesn't work but is there a way to do that?
Not sure whats wrong.. Its working for me as expected.
and this is the default filtering
Can you show me the error you get ? maybe there is another problem ?
Sorry you are correct it does work. My request was just timing out because it was doing a LIKE search.
How do I make it do an exact search? This is the data being sent to the server
columns[9][data]: phone_number
columns[9][name]:
columns[9][searchable]: true
columns[9][orderable]: true
columns[9][search][value]: ^123456$
columns[9][search][regex]: true
Also is there a way to filter on multiple columns with OR? Say for example the column being searched is phone_number
I would like the query to be where phone_number = 'value' or some_other_column = 'value'
When you type in search input, all columns that has searchable: true
are being search with "LIKE" and merged with 'OR'.
Lets say, you need to filter by full text, then you can bypass default filter like :
$dt->filter('test_test', function () {
return $this->column->name.' = '. $this->escape($this->searchValue());
});
Thanks. Now how would I make that filter apply only when searchValue() has a value?
Ah sorry, here it is:
$dt->filter('test_test', function () {
if ($this->searchValue() === '') {
return;
}
return $this->column->name.' = '. $this->escape($this->searchValue());
});
I just looked at the getQuery() log and that still causes the search term to be added to the query when its empty
Yea you are right, can you try this one ?
$dt->filter('test_test', function () {
if ($this->searchValue() === '') {
return '';
}
return $this->column->name.' = '. $this->escape($this->searchValue());
});
That works. Thanks again for all the help!!
Tables with dashed column names causes an error
This works:
This causes an error: