fixed getBy*()

This commit is contained in:
Steffen Vogel 2010-06-08 19:01:45 +02:00
parent 56b56dd93b
commit 888fc0aa1a
4 changed files with 10 additions and 12 deletions

View file

@ -25,9 +25,7 @@ class DataController extends Controller {
$channel = Channel::getByUcid($ucid);
// TODO add channel if it doesn't exist (use $this->add)
$channel->addData($this->view->request->get);
$channel->addData($this->view->request->get); // array(timestamp, value, count)
}
public function get() {
@ -39,7 +37,7 @@ class DataController extends Controller {
$groupBy = (isset($this->view->request->get['groupby'])) ? $this->view->request->get['groupby'] : 400; // get all readings by default
$data['from'] = $from; // TODO use min max timestamps from Channel::getData()
$data['to'] = $to;
$data['to'] = $to; // TODO nescessary?
$jsonChannels = array();
foreach ($channels as $channel) {

View file

@ -137,9 +137,9 @@ abstract class Channel extends DatabaseObject implements ChannelInterface {
* simple self::getByFilter() wrapper
*/
static public function getByUcid($ucid) {
$channel = self::getByFilter(array('ucid' => $ucid));
$channel = current(self::getByFilter(array('ucid' => $ucid)));
if (current($channel) === false) {
if ($channel === false) {
throw new InvalidArgumentException('No such channel!');
}

View file

@ -38,9 +38,9 @@ class Group extends DatabaseObject {
}
public static function getByUgid($ugid) {
$group = self::getByFilter(array('ugid' => $ugid));
$group = current(self::getByFilter(array('ugid' => $ugid)));
if (current($group) === false) {
if ($group === false) {
throw new InvalidArgumentException('No such group!');
}

View file

@ -29,9 +29,9 @@ class User extends DatabaseObject {
* simple self::getByFilter() wrapper
*/
public static function getByUuid($uuid) {
$user = self::getByFilter(array('uuid' => $uuid));
$user = current(self::getByFilter(array('uuid' => $uuid)));
if (current($user) === false) {
if ($user === false) {
throw new InvalidArgumentException('No such user!');
}
@ -39,9 +39,9 @@ class User extends DatabaseObject {
}
public static function getByEMail($email) {
$user = self::getByFilter(array('email' => $email));
$user = current(self::getByFilter(array('email' => $email)));
if (current($user) === false) {
if ($user === false) {
throw new InvalidArgumentException('No such user!');
}