title: Complex INSERTs (mysql Geometry POINT) with Doctrine in Symfony 1.4.x
body: <p>I'm using symfony 1.4.10, and trying to do a rather complex INSERT into a MySQL table. I'm using MySQL's geometry functions to store a set of latitude, longitude coordinates in a form where I can easily do proximity searches (that's just the background, not really too relevant).</p>
  
  <p>Here's what I'd like to do in raw SQL:</p>
  
  <pre><code>INSERT INTO video_geo (vimeo_vid, coord) 
       VALUES ( 15702113, GeomFromText( 'POINT(-122.415 37.7792)' ));
  </code></pre>
  
  <p>UPDATE: I'm pretty sure the issue is the parameter "mismatch" with POINT. POINT takes two 'params', lat and lon but it's one column in the DB. Not sure how to apply prepared statement to it (how many question marks and what to give it, a string?)</p>
  
  <p>I'm trying to use a "raw query" with Doctrine, but I can't find too much <em>detailed</em> documentation on it (only really basic examples from which it's hard to extrapolate).</p>
  
  <p>This is my latest trial-and-error attempt:</p>
  
  <pre><code>&lt;?php
  $connection = Doctrine_Manager::connection();
  $query = "INSERT INTO video_geo (vimeo_vid, coord) VALUES( ? , GeomFromText( 'POINT( ? ? )' ));";
  $statement = $connection-&gt;prepare($query);
  $statement-&gt;bindValue(1, $vimeoID);
  $statement-&gt;bindValue(2, $lat);
  $statement-&gt;bindValue(3, $lon);
  $statement-&gt;execute();
  ?&gt;
  </code></pre>
  
  <p>This results in the following error:</p>
  
  <p>In the sf log:</p>
  
  <blockquote>
    <p>Oct 28 22:58:14 symfony [info] {Doctrine_Connection_Statement} execute : INSERT INTO video_geo (vimeo_vid,  coord) VALUES( ?, GeomFromText( 'POINT( ? ? )' )); - ()</p>
  </blockquote>
  
  <p>Exception dumped:</p>
  
  <blockquote>
    <p>Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in...</p>
  </blockquote>
  
  <p>I'm thinking the issue is with POINT...should I be passing one parameter? I'm not sure what the type is.</p>
  
  <p>The example in the symfony manual doesn't show how to do prepared statements, I think that's the info I'm looking for here.</p>
  
  <p>Any help appreciated! Thx...</p>
  
  <p>Peter</p>