Alexandr and Wayne ! you saved my life!!

Thanks so much.. it's so simple I feel confused ^_^
I did not look closer to the spelling (and may have been tired of
breaking my teeth)

<b>The trick is just to define the type of  'id' as INTEGER instead of
INT .... (and to set it as PRIMARY)</b>

This is something so obvious.. but it isn't written anywhere for
cakePHP (actually there is very few documentation about using sqlite
with cake), now these notes may help somebody else..

Thank you very much all for your rapid answer !!

ps. and Adwin, I may keep your easiest method for next esoteric
vacation :P
pps. Thiago, we now have an easiest way to go


On Oct 25, 7:32 am, "Thiago Paes" <[EMAIL PROTECTED]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to