Comments (5)
But we will encounter a question here, if we input any string in the search funcition key of the Datatables, the
where
query set inside thenoticeTable
will become invalid.
That was the Problem! This Problem can be Prevented by changing the TablesIgniter.php
TablesIngiter.php
Edit the function extraConfig
Surround the foreach ($this->searchLike as $key => $field) in the with
$bui->groupStart(); and $bui->groupEnd();
so that it looks like:
if(!empty($_POST["search"]["value"])){
$bui->groupStart();
foreach ($this->searchLike as $key => $field) {
if($key == 0){
$bui->like($field,$_POST["search"]["value"]);
}
else{
$bui->orLike($field,$_POST["search"]["value"]);
}
}
$bui->groupEnd();
}
If you surround the forech with a groupStart() and a groupEnd() the query inside the notice Table keeps valid.
from tablesigniter.
I solved the Problem. Surround the foreach ($this->searchLike as $key => $field) in the function extraConfig with
$bui->groupStart(); and $bui->groupEnd();
so that it looks like:
if(!empty($_POST["search"]["value"])){ $bui->groupStart(); foreach ($this->searchLike as $key => $field) { if($key == 0){ $bui->like($field,$_POST["search"]["value"]); }else{ $bui->orLike($field,$_POST["search"]["value"]); } } $bui->groupEnd(); }
Then only Entries from the Builder are shown.
from tablesigniter.
Hi there !
Can you provide part of your configuration inside your Controller relating to the TableIgniter?
This really helps me debug.
According to your question, I tried to revert the possible situation. Take the sample codes as an example:
controller
public function fullTable(){
$model = new HomeModel();
$table = new TablesIgniter();
$table->setTable($model->noticeTable())
->setDefaultOrder("id","DESC")
->setSearch(["title","date"])
->setOrder([null,null,"date"])
->setOutput([$model->button(),"title","date"]);
return $table->getDatatable();
}
Model
public function noticeTable(){
$builder = $this->db->table("news")
->where('date','2020-01-04');
return $builder;
}
According to the codes above, the builder
inside noticeTable
will only illustrate the date
content as 2020-01-04
.
But we will encounter a question here, if we input any string in the search funcition key of the Datatables, the where
query set inside the noticeTable
will become invalid.
The cause of this question is the configuration of the Controller have confilct with the builder.
Lets take a look at the 6th line of the sample Controller: ->setSearch(["title", "date"])
.
In the TablesIgniter, the builder you transmit will become the foundation of all SQL Query. If you have already defined a rule that can filter some field with Where statement inside the builder, then the field should not be seen in the configuration of setSearch()
of the TablesIgniter.
If we revise the ->setSearch(["title","date"])
inside the sample program into ->serSearch(["title"])
, you will find out that everything works normally.
from tablesigniter.
OK,I get it!
I will fix this problem in the next version.
Thank you for your feedback!
from tablesigniter.
Hi, you can update to the v1.2.0 version, which fixes the above problem.
from tablesigniter.
Related Issues (11)
- Wanna ask HOT 1
- class not found HOT 24
- throws exception HOT 1
- CI 3 HOT 4
- Undefined index: draw HOT 3
- Not working with Searchpanes - Not supported? HOT 3
- Model builder HOT 1
- Custom icon as an output on table HOT 3
- Problems with PHP 8
- how to implement column search HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tablesigniter.