Introduction and tutorials to the new ORMqueryphp framework many php frameworks on the Internet at present domestic thinkphp is still good qeephp is also good, but I often use symfony abroad to write too much code when writing programs, this is indeed a very good framework, and there are a lot of automated and elegant verification methods. Automatic form is more open than the awkward verification method in China. But it feels too automatic. sometimes you have to write a plug-in yourself and get started with the new sym ORM queryphp framework.
Many php frameworks on the Internet
Domestic thinkphp is still good, and qeephp is also good, but too much code should be written when writing programs
I often use symfony abroad. this is indeed a very good framework, and there are many automated, beautiful verification methods, automatic form
It is more open than the awkward verification method in China.
But it feels too automatic. sometimes you have to write a plug-in by yourself if you want to do it manually.
Symfony was a little slow for the first time, but many plug-ins doctrine implemented jquery operations.
Only the js framework jquery is relatively small, and google also gives CDN, so the traffic on its own server is also small.
So a few days after the Chinese New Year, I developed the queryphp framework, a kind of jquery operation method to write php programs.
For example, both supply and books are database tables.
Echo $ supply-> Books-> classname; // automatically retrieve the content in Books
Echo $ supply-> Books-> Supply-> title; // Obtain the content in supply.
Echo $ supply-> title;
Echo $ books-> classname;
The hasOne hasMany ManyhasMany method is also supported.
Also supported by PATH_INFO
Testframework. php? Controller = default & action = index
Testframework. php/default/index
You can use apache to rewrite and remove the testframework. php file.
Below are some tutorials
This micro-frame
MVC mode can be implemented
Support path_info
The control action is under the router directory.
/Default/index
Call the defaultRouter. class. php file under the router directory.
Call the index method after obtaining the class
J () is the index method jump
R () is controlled
C () is the generation class
M () is the database-class model. The Database link is set in model. function. php.
Only the framework. php file is included.
Path_info mode
Testframework. php? Controller = default & action = index
Testframework. php/default/index
You can use apache to rewrite and remove the testframework. php file.
You can set routing rules yourself.
C ("router")-> ruleMaps ("login", '/login/: ID', array ('controller' => 'auth ', 'action' => 'login '));
Testframework. php/login/5555
In this way, you can use $ _ GET ['id'] to GET 5555;
'Controller' => 'auth', 'Action' => 'login'
Yes 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 ')); // will 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
Usage
Construct a database table model
$ Beian = M ('beian ');
The aaa bbb field $ _ POST must be filled automatically.
// $ Beian-> autoField (array ("aaa", "bbbb "));
$ Data filling
$ Beian-> autoField ($ data, array ("aaa", "bbbb "));
Take two primary key values and sort them in ascending order.
// Print_r ($ beian-> get (53,54, 'asc '));
Assign a value to a field.
$ Beian-> userid = 2;
$ Beian-> language = 1;
Print assigned fields
// Print_r ($ beian-> data );
Save and then display the inserted ID
// Echo $ beian-> save ()-> pkid ();
Set the primary key and delete it.
// Echo ($ beian-> pkid (69)-> delete ());
Obtain the number of rows in the table.
// Echo $ beian-> Totalnum ();
Select displays two fields. Arraylist is an array.
// Print_r ($ beian-> getAll ("userid, language")-> record); // changed to record.
Query two userid and language values: 1 and 5. the fetch value is
Print_r ($ beian-> whereUseridAndLanguage ('1', '5')-> fetch ()-> record );
Two primary keys are obtained. three fields are displayed in ascending order.
// Print_r ($ beian-> get ('confid, userid, language ', 'asc')-> record );
Output primary key value
// Echo $ beian-> confid;
Update the field of a table to accumulate 1
$ Beian-> colupdate ('tplid ');
You can add methods in the *** model. class. php file under the Model Directory.
The model can be used immediately after being generated.
Print_r ($ booktype = M ("booktype")-> getAll ());
Update the J () hop function
Allows you to redirect and transmit parameters between routes.
The parameter is array.
J ("show") is the route method to show
J ("show", array ("id" => 555) is to go to the current routing method show and pass the parameter ID
J (R ("member"), "list") will jump to the member route and call the list method. if there is no list, the default method is the index method. the default method is set in the framework.
J ("member ")
J ("member", "list", array ("userid" => 999 ))
HasOne hasMany ManyhasMany ORM (Object-Relational Mapper) Object ING can be changed in "map" => "hasOne ".
Automatic model file generation
PHP code
array("map"=>"hasOne","TargetModel"=>"booktype","localFiled"=>"typeid","targetFiled"=>"typeid")); var $maps;}?>