From: matt d. <mm_...@ya...> - 2010-04-16 12:33:08
|
I'm not sure 'no SQL' is all that desirable once you get past a single join. I prefer to build the query in MySQL query browser and after I have what I want use something simple like getQueryRows($q) If you where worried about clean data just run all $_REQUEST vars through a scrub globally. $_REQUEST = clean($_REQUEST); What's really helpful is if all your classes extend a basic representation of the table row as a class. The part where you say "table definitions in associative arrays" would be automatically handled there using "DESCRIBE $this->table" and populating $this->cols. Unless you are already doing that? You would also have things like: $foo = new foo(insert_row()); $foo->save($array); // uses set_row() and the built in table definition with validation or $foo2 = $foo->clone($override_data_array); // creates a new row overriding any column data with the passed array, Each class can define pre_clone child call $name = $foo->name(); // any column using "function __call($nm,$argv)" or overridden by a function and returns null if it doesn't exist formatting $foo_created = $foo>readableDate("created_date"); json $foo_json = $foo->json(); forms $html_form = $foo->getEditor(); Then you can have something like this: $users = getQueryObjects("select * from users where company_id = 1","user"); or $report = new reportTable($q,$reportclass,$displaycols); $report->display(); // sortable rows of data ________________________________ From: junkmail <jun...@2z...> To: Chicago PHP User Group <chi...@li...> Sent: Thu, April 15, 2010 5:19:47 PM Subject: [chiPHPug-discuss] Data Models I am curious what people use for fetching data in PHP. I've been calling this my model. Over the past few years I've slowly built up a framework that encompassed basic mysql_connect() and mysql_query() wrapping for error handling and simplicity. For the next step I made a basic query generator for 1-table CRUD operations using simple table definitions in associative arrays. The next step is for complex CRUD with table joins. This is the hard part that I'm not 100% sure how I should tackle it. I'm thinking it will start small, but ultimately I'll move to full-blown relationship modeling with the ability to perform CRUD operations across any relationship. My goal is to write little-to-NO hardcoded SQL into my PHP. I'm curious to hear about any strategies on this problem, or any insights that may have been encountered in similar endeavors. Thanks! ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ chiPHPug-discuss mailing list chi...@li... https://lists.sourceforge.net/lists/listinfo/chiphpug-discuss |