How to generate integer autoincrement ID feild in cakePHP using ichikaway mongodb plugin

637 views Asked by At

I am absolute dumb to mongoDB. I am using ichikaway cakephp-mongodb plugin to use mongoDB data-source in my cakephp 2.2 Application.

Here is snippet of my model User.php file:

<?php
class User extends AppModel {
    public $primaryKey = '_id';

    var $mongoSchema = array(
            'username'=>array('type'=>'string'),
            'password'=>array('type'=>'string'),
            'created'=>array('type'=>'datetime'),
            'modified'=>array('type'=>'datetime'),
            );

    public $validate = array( ...

This is generating an unique object id as shown in following mongoDB Document:

{
    "_id" : ObjectId("52cd469faca7b9880a8b4568"),
    "username" : "admin",
    "password" : "7c4a8d09ca3762af61e59520943dc26494f8941b",
    "modified" : ISODate("2014-01-08T12:37:51.292Z"),
    "created" : ISODate("2014-01-08T12:37:51.292Z")
}

I know that this objectID can be perfectly used as we do with unique Auto Increment Integer ID in SQL databases. As I can access it using _id field.

But even though, I want to generate Integer Auto Increment ID here. Please guide me.

0

There are 0 answers