php - Somehow a row is inserted twice even only one flush() exists; -
i made simple search form search query log.
in indexaction
public function indexaction(){ $searchlog = new searchlog; $form = $this->createformbuilder($searchlog) ->add('query','text') ->add('save', 'submit', array('label' => 'search')) ->setaction($this->generateurl('acme_top_searchresult')) ->getform();
'acme_top_searchresult' invokes searchresultaction(); receive query in searchresultaction
public function searchresultaction(request $request){ //var_dump($request); $searchlog = new searchlog; $form = $this->createformbuilder($searchlog) ->add('query') ->getform(); $form->handlerequest($request); $querydata = $form->getdata(); $this->em->persist($searchlog); $this->em->flush(); $sq = $querydata->getquery(); // use $sq searching
however inserted 2 rows in database. why happens??
i tried this.
public function searchresultaction(request $request){ $searchlog = new searchlog(); $form = $this->createformbuilder($searchlog) ->add('query') ->getform(); $form->handlerequest($request); if ($form->isvalid()){// dose not return true
however $form->isvalid() not return true
i paste var_dump($request) log below.
it lookes submit has done well...... me ???
object(symfony\component\httpfoundation\request)[3] public 'attributes' => object(symfony\component\httpfoundation\parameterbag)[6] protected 'parameters' => array (size=3) '_controller' => string 'acme\topbundle\controller\defaultcontroller::searchresultaction' (length=63) '_route' => string 'acme_top_searchresult' (length=21) '_route_params' => array (size=0) empty public 'request' => object(symfony\component\httpfoundation\parameterbag)[4] protected 'parameters' => array (size=1) 'form' => array (size=3) 'query' => string 'rarara' (length=6) 'save' => string '' (length=0) '_token' => string 'quf1zju3evtvnc3lkfdqr2z_-ouqng2ftds8vrtgucs' (length=43) public 'query' => object(symfony\component\httpfoundation\parameterbag)[5] protected 'parameters' => array (size=0) empty public 'server' => object(symfony\component\httpfoundation\serverbag)[9]myapp protected 'parameters' => array (size=37) 'http_host' => string 'localhost' (length=9) 'http_connection' => string 'keep-alive' (length=10) 'content_length' => string '99' (length=2) 'http_cache_control' => string 'max-age=0' (length=9) 'http_accept' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' (length=74) 'http_origin' => string 'http://localhost' (length=16) 'http_user_agent' => string 'mozilla/5.0 (macintosh; intel mac os x 10_10_2) applewebkit/537.36 (khtml, gecko) chrome/43.0.2357.132 safari/537.36' (length=121) 'content_type' => string 'application/x-www-form-urlencoded' (length=33) 'http_referer' => string 'http://localhost/myapp/web/app_dev.php/' (length=43) 'http_accept_encoding' => string 'gzip, deflate' (length=13) 'http_accept_language' => string 'ja,en-us;q=0.8,en;q=0.6' (length=23) 'http_cookie' => string 'phpsessid=iqpa901b7sfurcs9kvlkis3v52' (length=36) 'path' => string '/usr/bin:/bin:/usr/sbin:/sbin' (length=29) 'server_signature' => string '' (length=0) 'server_software' => string 'apache/2.4.9 (unix) php/5.6.9' (length=29) 'server_name' => string 'localhost' (length=9) 'server_addr' => string '::1' (length=3) 'server_port' => string '80' (length=2) 'remote_addr' => string '::1' (length=3) 'document_root' => string '/users/myname/codingworks/httproot' (length=34) 'request_scheme' => string 'http' (length=4) 'context_prefix' => string '' (length=0) 'context_document_root' => string '/users/myname/codingworks/httproot' (length=34) 'server_admin' => string 'you@example.com' (length=15) 'script_filename' => string '/users/myname/codingworks/httproot/myapp/web/app_dev.php' (length=60) 'remote_port' => string '51319' (length=5) 'gateway_interface' => string 'cgi/1.1' (length=7) 'server_protocol' => string 'http/1.1' (length=8) 'request_method' => string 'post' (length=4) 'query_string' => string '' (length=0) 'request_uri' => string '/myapp/web/app_dev.php/sr' (length=29) 'script_name' => string '/myapp/web/app_dev.php' (length=26) 'path_info' => string '/sr' (length=3) 'path_translated' => string '/users/myname/codingworks/httproot/sr' (length=37) 'php_self' => string '/myapp/web/app_dev.php/sr' (length=29) 'request_time_float' => float 1436891356.666 'request_time' => int 1436891356 public 'files' => object(symfony\component\httpfoundation\filebag)[8] protected 'parameters' => array (size=0) empty public 'cookies' => object(symfony\component\httpfoundation\parameterbag)[7] protected 'parameters' => array (size=1) 'phpsessid' => string 'iqpa901b7sfurcs9kvlkis3v52' (length=26) public 'headers' => object(symfony\component\httpfoundation\headerbag)[10] protected 'headers' => array (size=13) 'host' => array (size=1) 0 => string 'localhost' (length=9) 'connection' => array (size=1) 0 => string 'keep-alive' (length=10) 'content-length' => array (size=1) 0 => string '99' (length=2) 'cache-control' => array (size=1) 0 => string 'max-age=0' (length=9) 'accept' => array (size=1) 0 => string 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' (length=74) 'origin' => array (size=1) 0 => string 'http://localhost' (length=16) 'user-agent' => array (size=1) 0 => string 'mozilla/5.0 (macintosh; intel mac os x 10_10_2) applewebkit/537.36 (khtml, gecko) chrome/43.0.2357.132 safari/537.36' (length=121) 'content-type' => array (size=1) 0 => string 'application/x-www-form-urlencoded' (length=33) 'referer' => array (size=1) 0 => string 'http://localhost/myapp/web/app_dev.php/' (length=43) 'accept-encoding' => array (size=1) 0 => string 'gzip, deflate' (length=13) 'accept-language' => array (size=1) 0 => string 'ja,en-us;q=0.8,en;q=0.6' (length=23) 'cookie' => array (size=1) 0 => string 'phpsessid=iqpa901b7sfurcs9kvlkis3v52' (length=36) 'x-php-ob-level' => array (size=1) 0 => int 1 protected 'cachecontrol' => array (size=1) 'max-age' => string '0' (length=1) protected 'content' => null protected 'languages' => null protected 'charsets' => null protected 'encodings' => null protected 'acceptablecontenttypes' => null protected 'pathinfo' => string '/sr' (length=3) protected 'requesturi' => string '/myapp/web/app_dev.php/sr' (length=29) protected 'baseurl' => string '/myapp/web/app_dev.php' (length=26) protected 'basepath' => null protected 'method' => string 'post' (length=4) protected 'format' => null protected 'session' => object(symfony\component\httpfoundation\session\session)[58] protected 'storage' => object(symfony\component\httpfoundation\session\storage\nativesessionstorage)[57] protected 'bags' => array (size=2) 'attributes' => object(symfony\component\httpfoundation\session\attribute\attributebag)[435] private 'name' => string 'attributes' (length=10) private 'storagekey' => string '_sf2_attributes' (length=15) protected 'attributes' => & array (size=5) '_csrf/form' => string 'quf1zju3evtvnc3lkfdqr2z_-ouqng2ftds8vrtgucs' (length=43) '_locale' => string 'en' (length=2) '_csrf/authenticate' => string 'ojhfu-vzujlbbmayza7fknysd_oam_m1e35w_-qjkhe' (length=43) '_security_main' => string 'c:68:"hwi\bundle\oauthbundle\security\core\authentication\token\oauthtoken":1098:{a:7:{i:0;s:218:"caafdj1jc7iabaephpntzbdjzaib74qgesl5k0cewwvghnfnk7kgrytzn9ssmfa6pasjimsudxhhlulqsxxerllrkxtpaaxu7ygomeglahujk6udb8nrcthhtkjdlwxpgsfy3esegw9dpgbzawisedr5xitnwab6b6xk4egxloq8vmzczbebj4zbj5rghcpezcseluf6zaazsvk7rzbisdhg7j";i:1;a:2:{s:12:"access_token";s:218:"caafdj1jc7iabaephpntzbdjzaib74qgesl5k0cewwvghnfnk7kgrytzn9ssmfa6pasjimsudxhhlulqsxxerllrkxtpaaxu7ygomeglahujk6udb8nrcthhtkjdlwxpgsfy3esegw9dpgbzawisedr5xitnwab6b6xk4egxloq8vmzczbebj4zbj5rghcpezcseluf6zaazsvk7rzbisdhg7j";s:7:"expires";s:7:"5150639";}i:2;n;i:3;s:7:"5150639";i:4;i:1436891127;i:5;s:8:"facebook";i:6;s:503:"a:4:{i:0;c:27:"acme\userbundle\entity\user":166:{a:9:{i:0;s:8:"zkkyzy84";i:1;s:31:"2bhrsabaoh7okoc8cc8cg0o4swccc0c";i:2;s:17:"10201664509493403";i:3;s:17:"10201664509493403";i:4;b:0;i:5;b:0;i:6;b:0;i:7;b:1;i:8;i:1;}}i:1;b:1;i:2;a:2:{i:0;o:41:"symfony\component\security\core\role\role":1:{s:47:"�symfony\component\security\core\role\role�role";s:10:"role_admin";}i:1;o:41:"symfony\component\security\core\role\role":1:{s:47:"�symfony\component\security\core\role\role�role";s:9:"role_user";}}i:3;a:0:{}}";}}' (length=1181) '_csrf/sonata.batch' => string 't0fj67l9s_2fn1ya-zlspeortbvr0f7fryzsjbjedfs' (length=43) 'flashes' => object(symfony\component\httpfoundation\session\flash\flashbag)[436] private 'name' => string 'flashes' (length=7) private 'flashes' => & array (size=0) empty private 'storagekey' => string '_sf2_flashes' (length=12) protected 'started' => boolean true protected 'closed' => boolean false protected 'savehandler' => object(symfony\component\httpfoundation\session\storage\proxy\sessionhandlerproxy)[432] protected 'handler' => object(symfony\component\httpfoundation\session\storage\handler\nativefilesessionhandler)[56] protected 'wrapper' => boolean true protected 'active' => boolean true protected 'savehandlername' => string 'files' (length=5) protected 'metadatabag' => object(symfony\component\httpfoundation\session\storage\metadatabag)[55] private 'name' => string '__metadata' (length=10) private 'storagekey' => string '_sf2_meta' (length=9) protected 'meta' => & array (size=3) 'u' => int 1436891357 'c' => int 1436891127 'l' => string '0' (length=1) private 'lastused' => int 1436891143 private 'updatethreshold' => string '0' (length=1) private 'flashname' => string 'flashes' (length=7) private 'attributename' => string 'attributes' (length=10) protected 'locale' => string 'en' (length=2) protected 'defaultlocale' => string 'en' (length=2)
Comments
Post a Comment