public function testExtract() { $users = $this->users; $usernames = a::extract($users, 'username'); $this->assertEquals(array('peter', 'paul', 'mary'), $usernames); }
/** * Returns only values from a single column * * @param string $column * @return mixed */ public function column($column) { $results = $this->query($this->select($column)->order($this->primaryKeyName . ' ASC')->build('select'), array('iterator' => 'array', 'fetch' => 'array')); $results = a::extract($results, $column); if ($this->iterator == 'array') { return $results; } $iterator = $this->iterator; return new $iterator($results); }
/** * Returns only values from a single column * * @param string $column * @return mixed */ public function column($column) { $sql = new SQL($this->database, $this); $primaryKey = $sql->combineIdentifier($this->table, $this->primaryKeyName); $results = $this->query($this->select(array($column))->order($primaryKey . ' ASC')->build('select'), array('iterator' => 'array', 'fetch' => 'array')); $results = a::extract($results, $column); if ($this->iterator == 'array') { return $results; } $iterator = $this->iterator; return new $iterator($results); }