简体   繁体   English

MySQL 错误...#1305

[英]MySQL error…#1305

I've had below error occurred when I queried this through my controller in Cakephp for MySQL query.当我通过 Cakephp 中的 controller 查询 MySQL 查询时,发生了以下错误。

SELECT id, 6371 * ACos(COS(RADIANS(users.latitude)) * Cos
                        (RADIANS(35)) * Cos(RADIANS(33) - RADIANS
                        (users.longitude)) + Sin(RADIANS(users.latitude)) * Sin
                        (RADIANS(35)) ) AS distance
                        FROM users
                        ORDER BY distance
                        LIMIT 20;

I'm stuck here...Do anyone know what this problem is?我被困在这里...有人知道这是什么问题吗?

Warning (512): SQL Error: 1305: FUNCTION wmetools_track.Cos does not exist [APP/cake/libs/model/datasources/dbo_source.php, line 684]
Code | Context

DboSource::showQuery() - APP/cake/libs/model/datasources/dbo_source.php, line 684
DboSource::execute() - APP/cake/libs/model/datasources/dbo_source.php, line 266
DboSource::fetchAll() - APP/cake/libs/model/datasources/dbo_source.php, line 410
DboSource::query() - APP/cake/libs/model/datasources/dbo_source.php, line 287
Model::query() - APP/cake/libs/model/model.php, line 2463
UsersController::api_localusers() - APP/controllers/users_controller.php, line 88
Dispatcher::_invoke() - APP/cake/dispatcher.php, line 204
Dispatcher::dispatch() - APP/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 83

It looks like MySQL doesn't like the whitespace between the function name and the opening parenthesis.看起来 MySQL 不喜欢 function 名称和左括号之间的空格。

select cos    (0.4) -- error
select cos(0.4) -- works

edit: The MySQL Documentation supports this.编辑: MySQL 文档支持这一点。 But apparently there's a Workaround: using the "IGNORE_SPACE" should solve your problem (a part from just removing the whitespace between the function name and the opening parenthesis).但显然有一个解决方法:使用“IGNORE_SPACE”应该可以解决您的问题(只是删除 function 名称和左括号之间的空格的一部分)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM