Auto POG Class Generator

37 views
Skip to first unread message

Mario

unread,
Jul 5, 2011, 5:55:45 AM7/5/11
to php-object-generator
Hello everybody,

   I've developed an small code for automaticaly generate on the fly a class code equivalent to what the POG generator does,
using the information available directly from database metainfo. I have not tested with other plugins but I don't see
any problem as it respects the "pog_attribute_type" attribute.

   The use is truly easy, for example, if you have a table in your database called "cursos", just write the code and use:

$curso = new cursos();
$curso = $curso->Get(857);
echo $curso->id, ":", $curso->denominacion, "\n", var_dump($curso->pog_attribute_type);
$cursos = $curso->GetList(array(),"",true,1);
if (count($cursos)==1)
{
$curso = $cursos[0];
echo $curso->id, ":", $curso->denominacion, "\n", var_dump($curso->pog_attribute_type);
}


Summary:

Flaws:
  • It is not 100% compatible as it doesn't support Save or Delete functions YET.
  • It doesn't respect the naming convenctions for class ids (for example "objectId") either.
  • It doesn't work with parent/sibling relationships, like POG does.
Pros:
  • You may read from the database directly using objects, Get and GetList methods.
  • It should work with most POG plugins.



Feel free to comment and request more functionality.

Have a nice day! :-)


Message has been deleted

Loksly

unread,
Jul 12, 2011, 9:10:35 AM7/12/11
to Php Object Generator
Now it works for tables with more than one primary key. For example.

$object = $object->Get(1, 2, 3); //order cames from database
declaration (describe), they should be numeric-fields.

http://pastie.org/private/ckwtlzpfhwsdric1aemwow

Does it anyone find it interesting?

Have a nice day!
Reply all
Reply to author
Forward
0 new messages