Introduction to the new ORM queryphp Framework and introductory tutorials
Currently many PHP frameworks on the web
Domestic thinkphp is good qeephp is also good, but write program time to write too much code
I often use symfony abroad, this is really a very good framework, but also a lot of automation, graceful verification method, automatic form
It's more open than the awkward way of proving in our country.
But feel too automatic, sometimes want to hand down, you have to write a plugin
And symfony the first time a bit slow, but the plug-in multi-doctrine implementation of the jquery operation mode
Can stick to use down only JS framework jquery jquery is also relatively small, Google also to CDN, so its own server traffic is also small
So after a few days after the new year developed the queryphp framework, a kind of quasi-jquery operation Way to write PHP program.
such as: supply and books are database tables.
echo $supply->books->classname;//automatically get content in Books
Echo $supply->books->supply->title; In turn, take the contents of supply
Echo $supply->title;
Echo $books->classname;
also supports Hasone hasmany Manyhasmany Mode Association
and Path_info also supports
Testframework.php?controller=default&action=index
Testframework.php/default/index
You can use Apache rewrite to remove testframework.php files
Post some tutorials below
This one miniature frame
The MVC approach can be implemented
Support Path_info Mode
Control action under the router directory
/default/index
Call the router directory under the defaultRouter.class.php file
Call Index mode after getting class
J () is the index method jump
R () is controlled by the
C () is the generated class
M () is a database-class model database link set inside the model.function.php
Just include the framework.php file.
Path_info Way
Testframework.php?controller=default&action=index
Testframework.php/default/index
You can use Apache rewrite to remove testframework.php files
You can set up your own routing rules
C ("router")->rulemaps ("Login", '/login/:id ', Array (' controller ' = ' auth ', ' action ' = ' login '));
Then it will be a testframework.php/login/5555.
This allows the use of $_get[' ID '] to get 5555;
' Controller ' = ' auth ', ' action ' = ' login '
is the controller and method
Other settings
C ("router")->rulemaps (' logout ', '/logout ', Array (' controller ' = ' auth ', ' action ' = ' logout '));
C ("router")->rulemaps (' Signup ', '/signup ', Array (' controller ' = ' auth ', ' action ' = ' signup '));
C ("router")->rulemaps (' profile ', '/profile/:action ', Array (' controller ' = ' profile ')); Would call controller ' profile ' with dynamic method ': Action () '
C ("router")->rulemaps (' Users ', '/users/:id ', Array (' controller ' = ' users '), array (' id ' = ' = ' [\d]{1,8} ')]; Define filters for the URL parameters
Database Data Model
How to use
Constructing a database table model
$beian =m (' Beian ');
Auto-populate AAA BBB field $_post also have these two fields
$beian->autofield (Array ("AAA", "bbbb"));
Fill in $data
$beian->autofield ($data, Array ("AAA", "bbbb"));
Takes two primary key values, sorted in ascending order
Print_r ($beian->get (53,54, ' ASC '));
Assignment to a field.
$beian->userid=2;
$beian->language=1;
Print an already assigned field
Print_r ($beian->data);
Save and then display the ID you just inserted
echo $beian->save ()->pkid ();
Set the primary key and then delete
Echo ($beian->pkid ()->delete ());
Gets the number of rows in the table
echo $beian->totalnum ();
Select displays two fields, ArrayList an array
Print_r ($beian->getall ("Userid,language")->record); Change to record.
Query two UserID and language for 1 and 5,fetch for value
Print_r ($beian->whereuseridandlanguage (' 1 ', ' 5 ')->fetch ()->record);
Get two primary keys, display three fields, ascending
Print_r ($beian->get (' Confid,userid,language ', 53,54, ' ASC ')->record);
Output PRIMARY Key value
Echo $beian->confid;
Update field of a table cumulative 1
$beian->colupdate (' tplid ');
You can add a method to the *****model.class.php file in the Model directory.
Can be used immediately after the model is generated
Print_r ($booktype =m ("BookType")->getall ());
Update j () Jump function
can support jump and pass parameters between individual routes
parameter is array
J ("show") for go to this route method show
J ("Show", Array ("id" =>555)) for go to this route method show and pass the parameter ID past
J (R ("member"), "list") will jump to the member route and call the list method if there is no list then default to the index method, the default method set in the specific framework.
J ("member")
J ("Member", "List", Array ("userid" =>999))
HasOne hasmany manyhasmany ORM (object-relational Mapper) Object Relationship Mapping There are three kinds of "map" and "HasOne" here to change
Automatic generation of model files
PHP Code
Array ("Map" = "HasOne", "targetmodel" = "BookType", "localfiled" = "typeID", "targetfiled" and "typeID"); var $maps;}? >