**アップデート2 *Symfonyでデータを取得する方法
私のSymfonyプロジェクトでは、「satelliteImage」という名前のテーブルがあります。この表には、緯度と経度という2つの属性があります。これらの2つの値を使用してエントリを取得したいとします。
/**
* @Route("/displayByNumber/{latitude}/{longitude}", name="satellite_images_display_latlon")
*/
public function displayByLatLonAction($latitude,$longitude)
{
$satelliteImage=$this->getDoctrine()
->getRepository('AppBundle:satelliteImage')
->findOneBy(array('latitude'=>$latitude,'longitude'=>$longitude));
$picture=base64_encode(stream_get_contents($satelliteImage->getImage()));
return $this->render('satelliteImages/display.html.twig',array(
'satelliteImage' => $satelliteImage,
'picture'=>$picture
));
}
例えば: - 緯度= 6.43435564545、経度= 78.456575545
Iは、その緯度と経度上記値未満であるすべてのエントリを取得します。私はこれを試してみましたが、あなたはパラメータの緯度と経度の両方に同じ値で開始する必要がありますレコードを検索したい場合は、何も
$query = $repository->createQueryBuilder('image')
->where('image.latitude< :nelatitude')
->andWhere('image.longitude< :nelongitude')
->setParameters(array(
'nelatitude'=> $nelatitude,
'nelongitude'=> $nelongitude,
))
//->orderBy('p.price', 'ASC')
->getQuery();
'LIKE'クエリでない場合は、'% 'を使用しないでください。あなたは基本的なSQLを勉強する必要があります。 – goto
@goto私はそれを更新しましたが、それでも価値がありません。私は浮動小数点を与えることができますか、それを文字列に変換する必要がありますか? –
クエリが正常に表示されます。データベースに適切なデータがあることを確認してください。 – goto