L
L
Lavrov952018-07-20 01:16:05
Zend Framework
Lavrov95, 2018-07-20 01:16:05

I can not get the IP from the database, who can help?

'id' => new Expression('(SELECT COUNT(`id`) FROM ' . $this->getTable() . ' WHERE `ip` = INET_ATON(' .  "$ip" . '))', []),

ERROR
Statement could not be executed (42000 - 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 '.0.1)) AS `id` FROM `survey_vote` ' at line 1)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2018-07-20
@Rsa97

Output the generated text of your request, find the place indicated in the error and look carefully.

Decision
INET_ATON принимает на вход строку.

R
Ruslan., 2018-07-20
@LaRN

When applying an aggregating function to a field, if you later need to refer to this field by name, you must specify an alias for the field, for example:
select count(id) as id from

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question