Skip to content

SQLSTATE[42000] OR SQLSTATE[42S22] #7

Description

@tagplus5

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`';

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions