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
Post a Comment