In my applications, that i have using sqlite 2, add this solution:
app_model:
function getNextId()
{
$_max = $this->query("SELECT (MAX(id) + 1) AS id FROM
{$this->table}");
$max = $_max[0][0]['id'];
return ceil($max);
}
and, in for example, photos_controller.php:
function add() {
if ($this->data) {
...
$this->data['Photo']['id'] = $this->Photo->getNextId();
...
}
}
Sorry for my bad english to explain the idea..
Thiago Paes
---
On 10/25/07, Grant Cox <[EMAIL PROTECTED]> wrote:
>
>
> That's "easy"? Sounds like a ridiculously over-complex idea to me...
>
>
> On Oct 25, 2:01 pm, Adwin Wijaya <[EMAIL PROTECTED]> wrote:
> > The easiest one :)
> >
> > create a table called counter with 2 field (or one,. deppend on you)
> > create table tcounter
> > :ctrtype "nameoftable"
> > :ctrvalue 0
> >
> > when you want to save (inserting) ... get the ctrvalue from the
> > tcounter first, and then insert the ctrvalue into your table :id
> > (primary key). dont forget to update the tcountr after you
> > successfully inserting (update tcountr set ctrvalue = ctrvalue + 1 )
> >
> > done :)
> >
>
--
________________________________________________________
Thiago Paes - WebDeveloper - Linux user: #224062
site: http://www.thiagopaes.com.br
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---