EntityToQuery()
Converts the input entity object or the input array of entity objects to a query object.
EntityToQuery( entity=object, name=string );
Returns: Query
| Argument | Description |
|---|---|
|
entity
object,
required
|
edit
entity or array of entities |
|
name
string,
optional
|
edit
name of the entities |
Usage Notes
editConverts an entity or array of entities into a CFML query object. Useful when you need tabular data for display, export, or passing to functions that expect query objects.
Only scalar properties are included in the query columns — relationships and complex types are excluded.
See ORM - Querying for alternatives like HQL projections.
Examples
edit// Convert an array of entities to a query
users = entityLoad( "User" );
qUsers = entityToQuery( users );
writeDump( qUsers );
// Convert a single entity
user = entityLoadByPK( "User", 42 );
qUser = entityToQuery( user );
See also
- ORM
- ORM - Querying
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)