score:12
Accepted answer
findoneby(array())
will always return null or object.
but you can use instead findbyid($userposting)
or findby(array('id' => $userposting))
and it will return an array, e.g.:
$this->getdoctrine()->getrepository('mybundle:users')->findbyid($userposting))
edited
or you can add a method in userrepository
class:
use doctrine\orm\entityrepository;
use doctrine\orm\query;
class userrepository extends entityrepository
{
public function getuser($userposting)
{
$qb = $this->createquerybuilder('u')
->select('u')
->where('u =:userposting')->setparameter('userposting', $userposting)
->getquery()
->getresult(query::hydrate_array);
return $qb;
}
}
Source: stackoverflow.com
Related Query
- How to return an array not an object with doctrine findOneBy method in symfony2?
- Return array, not object from Doctrine query - Symfony2
- Doctrine queryBuilder: return object not array
- symfony 4 with fixtures, the getReference method does not return the expected object (return PROXY/__CG__/... instead an instance of User class)
- Symfony4 / Doctrine, how select 'distinct' objects ? getResult() return an array of string, not an array of object
- how to check whether foreign key is working or not in symfony2 with doctrine
- Symfony2 doctrine: How to select users that are not in groups with doctrine query builder
- How to have doctrine querybuilder with where not clause return values when null
- Symfony2 - How to manage permissions with roles by action not by the object
- Return array with Doctrine findBy method
- How to add an array with values in Symfony2 configuration?
- Doctrine findOneBy method not working
- How to generate entities from database view with doctrine and symfony2
- How to select certain fields with mongodb doctrine in symfony2
- symfony2 - Doctrine - How to do a multiple select with a count and group by
- How to bind Symfony2 form with an array (not a request)?
- Symfony2 and Doctrine - return database result as array of arrays in controller
- Symfony2 - How to set Doctrine APC cache prefix with multiple apps
- How to test Doctrine Entity Manager findOneById method with prophecy?
- Symfony NelmioApiDocBundle swagger-ui PHP Annotations json object with array of objects properties not showing
- How to get object in different translations with Doctrine and Gedmo Translatable Extension
- How to check if object has method in Symfony2
- Symfony2 - How to query a left-join with a condition in doctrine 2
- How to delete document from a referenced array of documents in doctrine ODM with mongodb
- Symfony 2: How to use the ParamConverter with a PUT method to get or create an entity object
- How to configure Monolog to store logs into MongoDB with Symfony2 and Doctrine
- Return an associative array with certain key for a findBy doctrine repository function
- Symfony2 - How to change a document using a postLoad event-listener with Doctrine MongoDB ODM?
- How to handle File Uploads with Doctrine in Symfony2
- Doctrine querybuilder how to replace parameters with an array of parameters?
More Query from same tag
- Symfony Mailer Dynamic Transport from Database
- Asynchronous Process doesn't seem to work on my prod environment
- Symfony Controller should return response
- How can I generate an unique id in Symfony 4?
- sending e-mail in wamp Symfony 2
- How do you deal with route-based urls?
- Doctrine 2.1: How to orderBy aggregate field in a collection?
- relation many to one between two entities in two bundles symfony
- Symfony 2 - How to delete a bundle?
- How should one redirect locale-less URIs to locale-full ones in Symfony-CMF?
- How do I fix two competing symfony routes
- Two Instances of Symfony2 on the same server not behaving properly
- Symfony fetch/persist entity-oriented service naming conventions and best practice
- Symfony Options Resolver allow Invalid Options
- Manually Encode a Password in php symfony
- How to tag emails with symfony/mailer and symfony/mailgun-mailer provider
- Filter a listing in Symfony2?
- FOS user bundle authentication
- Symfony login with PHPUnit throws invalid CSRF token
- Error page based on host
- Symfony2 form renders one field with same name
- EasyAdmin 3 - CRUD with nested form
- Symfony Fos User Bundle : Link fos_user_group and roles
- PHP action not receiving Post variables from Python Script
- Populating checkboxes in Symfony2 based on ArrayCollection()
- create a custom controller back office on Custom module in prestashop
- Logging from inside a repository in Symfony
- How can I avoid applying attr to all options of my choice field?
- symfony add select option in materialize reload jquery
- serialize array of objects using Doctrine and JMSSerializer annotations