ssp
ssp copied to clipboard
SQLSTATE[42000] OR SQLSTATE[42S22]
When i set
// Table's primary key
$primaryKey = '`company`.`id`';
in ssp.class on this part
// Total data set length
$count_request = "SELECT COUNT(`{$primaryKey}`)";
if ($joinQuery) {
$count_request .= $joinQuery;
} else {
$count_request .= "FROM `$table`";
}
I get this sql:
SELECT COUNT(``company`.`id``) FROM `company` LEFT JOIN `city` ON `company`.`city` = `city`.`id`
And error
{"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 MySQL server version for the right syntax to use near 'company`.`id``) FROM `company` LEFT JOIN `city` ON `company`.`city` = `city`.`id' at line 1"}
And when i set
$primaryKey = 'company.id';
I get this sql:
SELECT COUNT(`company.id`) FROM `company` LEFT JOIN `city` ON `company`.`city` = `city`.`id`
And error
{"error":"An SQL error occurred: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'company.id' in 'field list'"}
I think that need set
$count_request = "SELECT COUNT({$primaryKey})";
without
`
And use
$primaryKey = '`company`.`id`';
Me too!