DATABASE:
id | name | // ...
====================
1 | London |
2 | Paris |
3 | Moscow |
4 | New York |
// ...
TEXT:
This is a big city. I live in this town.
I like the name of city. 'New York' is very cool.
However, I have to go to Moscow this summer.
// ...
There are a lot of records in the database.
Text is written in various languages.
I would like to get the records related to text.
In this case, I would like to get the records of 'New York' and 'Moscow'.
I am using a Doctrine2 ORM and DQL.
And my database is usually mysql.
Is it possible to achieve this by using the DQL?
UPDATE
City Entity : id, name, population date_created etc...
id | name | population | // ...
====================================
1 | London | 1,2448,3938|
2 | Paris | 1,8759,4844|
3 | Moscow |12,8450,3748|
4 | New York | 8,4795,8558|
// ...
Article Entity : id, body, author, date_created etc...
id | body | // ...
============================================================
1 | This is a big city. I live in this town. |
| I like the name of city. |
| 'New York' is very cool. |
| However, I have to go to Moscow this summer.|
| // ... |
2 | We bought a house in London. //... |
3 | I go to Canada this weekend. //... |
4 | Weather in Africa today is too bad. //... |
// ...
The text is good whether it get from a file or a database.
public function findOneById($id)
{
$query = $this->getEntityManager()->createQuery('
SELECT a, u
FROM MyArticleBundle:Article a
LEFT JOIN a.author u
WHERE a.id = :id
')
->setParameter('id', $id);
return $this->try_catch($query);
}
or
$article = file_get_contents('example.txt');
And I bring it to the display.
{{ article }} or {{ article.body }} etc...
At this time, how do I get the city data of related to this article?
Is it'll need a complex database configuration?
The text and entity (in this case 'city' data) has no association.
Is it possible that I get the data that appears in the text or strings?
such as : SELECT c FROM MyExampleBundle:City c WHERE c.name appear in ({$text});
Although I know the example is impossible, but I wanted to know whether there is a way to easily get like a that in DQL.