SSP class giving error on mysql syntax when using AS in naming columns array
SSP class giving error on mysql syntax when using AS in naming columns array
brian82
Posts: 7Questions: 3Answers: 0
Naming column using AS
$columns = array(
array( 'db' => 'a.name', 'dt' => 0, 'field' => 'name' ),
array( 'db' => 'a.date', 'dt' => 1, 'field' => 'date' ),
array( 'db' => 'c.name AS other_name', 'dt' => 2, 'field' => 'other_name' ), // this line
Error is happening when using AS
to change name of column and it happens on search input and on sorting that column.
this is actual error
An SQL error occurred: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS other_name LIKE '%test%'
when AS
is removed all works, but then it is problem because you have 2 same columns "name" and same "name" is displayed in both columns in datatable, you can see on image below.
$columns = array(
array( 'db' => 'a.name', 'dt' => 0, 'field' => 'name' ),
array( 'db' => 'a.date', 'dt' => 1, 'field' => 'date' ),
array( 'db' => 'c.name', 'dt' => 2, 'field' => 'name' ),
Answers
Have you tried
?
Yes, then i get error
Undefined index: other_name
Issue fixed you can check here https://github.com/emran/ssp/pull/29
Yes, the demo SSP script doesn't cope with aliases. The Editor PHP libraries are far more capable though, and do. They support server-side processing and are free under the MIT license.
Allan