php - Selection database rows and treat them as object -
php - Selection database rows and treat them as object -
i'm developing sort of "model" in i'd love able select few rows (or one) constructor , able treat them object example, selecting posts has "admin" author limit of 10 be:
$posts = new post(array( 'where' => array('author' => 'admin'), 'limit' => array(0 => 10), # optional: 'order' => array($by => 'desc/asc') )); # field $id = $posts->row[0]['id']; # editing fields $posts->row[1]['body'] = 'new body'; $posts->row[2]['body'] = 'new body post # 3'; $posts->update(); # delete selected posts $posts->delete(); ... et cetera.
but don't way select posts. seems mechanic , total of arrays in arrays don't like. thought "one object beingness 1 row" take require of 10 posts perform 10 different queries. , that's not efficient.
question #1 there similar pattern or similar script inspire me? first 1 think database rows seen php object (with pros come along concept).
question #2 there way of selecting multiple rows? solution forcefulness developer specify primary key of table (such post id) selector? (<= don't think solution @ all).
most orms (object-relational mappers) seek give answers question in 1 or way.
i suggest have @ doctrine , @ propel ideas. also, see @ other languages, such microsoft's linq .net.
myself, have published orm php called solid oxygen. have @ documentation, if want. believe did close seek develop.
php database
Comments
Post a Comment