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

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -