mysql - Symfony/Doctrine: How to iterate through table fields for hydration? -


after making sql query table post wish hydrate $result array doctrine object. right in order use set command each field, below:

      $post = new post();     $post->setcategory($result['category']);     $post->setname($result['name']);     $post->setrating($result['rating']);

my question is there better way this, such iterating through table fields? thanks.

you can use fromarray():

$post = new post(); $post->fromarray($results); 

Comments

Popular posts from this blog

forms - Secure PHP File Upload Script -

java - How do I override the spring framework version in Spring Batch? -

.net - Amazon EC2 API and Windows instances - any way to get drive letter assignment? -