Elgg\Database::getData PHP Method

getData() public method

Queries are executed with {@link \Elgg\Database::executeQuery()} and results are retrieved with {@link \PDO::fetchObject()}. If a callback function $callback is defined, each row will be passed as a single argument to $callback. If no callback function is defined, the entire result set is returned as an array.
public getData ( string $query, callable $callback = null, array $params = [] ) : array
$query string The query being passed.
$callback callable Optionally, the name of a function to call back to on each row
$params array Query params. E.g. [1, 'steve'] or [':id' => 1, ':name' => 'steve']
return array An array of database result objects or callback function results. If the query returned nothing, an empty array.
    public function getData($query, $callback = null, array $params = [])
    {
        return $this->getResults($query, $callback, false, $params);
    }

Usage Example

Esempio n. 1
0
 /**
  * Get all the relationships for a given GUID.
  *
  * @param int  $guid                 GUID of the subject or target entity (see $inverse)
  * @param bool $inverse_relationship Is $guid the target of the deleted relationships? By default $guid is
  *                                   the subject of the relationships.
  *
  * @return \ElggRelationship[]
  */
 public function getAll($guid, $inverse_relationship = false)
 {
     $guid = (int) $guid;
     $where = $inverse_relationship ? "guid_two='{$guid}'" : "guid_one='{$guid}'";
     $query = "SELECT * from {$this->db->getTablePrefix()}entity_relationships WHERE {$where}";
     return $this->db->getData($query, array($this, 'rowToElggRelationship'));
 }
All Usage Examples Of Elgg\Database::getData