On Tue, Oct 13, 2009 at 4:25 AM, Henrik Gemal <[email protected]> wrote:
>
> I have a table with:
> name, hour, status
>
> hour is the hour of the time.
>
> So I have to check each hour that name is ok and set the status.
> So eventually I get a table like:
>
> test, 1, 1
> test, 2, 0
> test, 3, 0
> ............
> test, 23, 1
>
> If I use:
> $data = array("Name" => array("status" => $status, "name" => $name,
> "hour" => $hour));
> $this->Name->save($data);
>
> it keeps on adding new lines. I only want one line per hour.
>
> How can I do this?
>
>
> >
>
Add a primary key ("id") to the table.
$id = $this->Name->field(
'id',
array(
'Name.name' => $name,
'Name.hour' => $hour
)
);
$this->Name->id = $id;
$this->Name->saveField('status', $status);
So, I guess you're just letting the data rotate. I mean, there are no
dates so the record for a particular hour is overwritten. Personally,
I'd consider adding a 'created' timestamp column and insert new record
each time. That way, you'd have lots of data with which to compile
stats. But perhaps you don't need that for this app.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---