⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

how can i change auto increment (primary key) to micro time format?



izzatz13
  • profile picture
  • Member

Posted 07 October 2012 - 19:25 PM

i've a previous project that using micro time as the primary key. so right now i want to know how can i change the auto increment been done by groc crud to micro time format instead

groc crud freshie here :wub:

victor
  • profile picture
  • Member

Posted 07 October 2012 - 19:39 PM

Hi! You can use
http://www.grocerycrud.com/documentation/options_functions/callback_before_insert
http://www.grocerycrud.com/documentation/options_functions/set_primary_key

izzatz13
  • profile picture
  • Member

Posted 07 October 2012 - 20:16 PM

thanks victor, but what i dont understand is, there is no micro time format for groc crud i supposed? how could i insert a new data using micro time format as a primary key. i've pre defined code that i've been using on a plain php

how can i intergrade that code with groc crud? do i've to create separate function for it?

victor
  • profile picture
  • Member

Posted 08 October 2012 - 06:12 AM




function crud()
{
......
$crud->callback_before_insert(array($this,'my_primary_key'));
......
}
function my_primary_key($post_array)
{
$post_array['your_primary_key_field'] = this->primary();
return $post_array;
}

function primary()
{
$primary = your code for creating primary key
return $primary
}