Thinkphp filtering problems

Source: Internet
Author: User
How can I select two fields for the thinkphp filter ~~


Reply to discussion (solution)

Become a sofa and wait for the answer from your master brother ~~

$ Model-> where ($ condition)-> select ();
$ Condition: just like normal SQL, you can write multiple conditions and connections.

TP has its own encapsulated functions for operations, or you can use SQL statements to perform operations. Depending on your needs, if it is very complex, write your own SQL to run, if not, the functions encapsulated by TP are enough. However, the upstairs method is sufficient if only two conditions such as LZ are used for query.

M ('tablename')-> where ("Position = 'XXX' and Recruitment = 'XXX'")-> select ();

$ Model-> where ($ condition)-> select ();
$ Condition: just like normal SQL, you can write multiple conditions and connections.




Sorry, it won't be written at all ~~ Can I write all the data ???? Newbie ~~

TP has its own encapsulated functions for operations, or you can use SQL statements to perform operations. Depending on your needs, if it is very complex, write your own SQL to run, if not, the functions encapsulated by TP are enough. However, the upstairs method is sufficient if only two conditions such as LZ are used for query.



Sorry, it won't be written at all ~~ Can I write all the data ???? Newbie ~~

TP has its own encapsulated functions for operations, or you can use SQL statements to perform operations. Depending on your needs, if it is very complex, write your own SQL to run, if not, the functions encapsulated by TP are enough. However, the upstairs method is sufficient if only two conditions such as LZ are used for query.



Sorry, it won't be written at all ~~ Can I write all the data ???? Newbie ~~


$ Model-> where ($ condition)-> select ();
$ Condition: just like normal SQL, you can write multiple conditions and connections.




Sorry, it won't be written at all ~~ Can I write all the data ???? Newbie ~~


$ Model = M ("tablename "); // replace tablename with your table name $ list = $ Model-> where ("Position = 'XXX' and Recruitment = 'XXX'")-> select (); // here, like writing SQL statements, you need to replace the xxx content with the condition $ this-> assign ("list", $ list) for your two fields ); // Finally, pass the query array results into the template and call the template cyclically.



$ Model-> where ($ condition)-> select ();
$ Condition: just like normal SQL, you can write multiple conditions and connections.




Sorry, it won't be written at all ~~ Can I write all the data ???? Newbie ~~


$ Model = M ("tablename "); // replace tablename with your table name $ list = $ Model-> where ("Position = 'XXX' and Recruitment = 'XXX'")-> select (); // here, like writing SQL statements, you need to replace the xxx content with the condition $ this-> assign ("list", $ list) for your two fields ); // Finally, pass the query array results into the template and call the template cyclically.



I just didn't understand how XXX passed the value.
Is it the first filter or another one?




$ Model-> where ($ condition)-> select ();
$ Condition: just like normal SQL, you can write multiple conditions and connections.




Sorry, it won't be written at all ~~ Can I write all the data ???? Newbie ~~


$ Model = M ("tablename "); // replace tablename with your table name $ list = $ Model-> where ("Position = 'XXX' and Recruitment = 'XXX'")-> select (); // here, like writing SQL statements, you need to replace the xxx content with the condition $ this-> assign ("list", $ list) for your two fields ); // Finally, pass the query array results into the template and call the template cyclically.



I just didn't understand how XXX passed the value.
Is it the first filter or another one?




Public function shaixuan (){
$ Data = M ('zhaopin ');
$ Aid = $ _ GET ['id'];
$ Lists = $ Data-> where ("Position = '$ aid' and Recruitment = '$ aid'")-> select ();
$ This-> assign ('lists', $ lists );
$ This-> display ('index ');
}




$ Model-> where ($ condition)-> select ();
$ Condition: just like normal SQL, you can write multiple conditions and connections.




Sorry, it won't be written at all ~~ Can I write all the data ???? Newbie ~~


$ Model = M ("tablename "); // replace tablename with your table name $ list = $ Model-> where ("Position = 'XXX' and Recruitment = 'XXX'")-> select (); // here, like writing SQL statements, you need to replace the xxx content with the condition $ this-> assign ("list", $ list) for your two fields ); // Finally, pass the query array results into the template and call the template cyclically.



I just didn't understand how XXX passed the value.
Is it the first filter or another one?


public function  shaixuan(){$data=M('zhaopin');$aid=$_GET['id'];$lists = $Data->where("Position = '$aid' and Recruitment = '$aid'")->select();$this->assign('lists',$lists);$this->display('index');}
 
  {$vo['Position']}
  

Khan, there is no rule on how to pass this xxx file. this is a condition, and the condition is that you want to use it to limit the results you want. then I will ask you, why do you need these two fields for parallel filtering? why not all fields are filtered! Similarly, if you want to filter records whose Position is 111, it is $ Data-> where ("Position = '000000'")-> select (); as for this 111, if it is dynamically transmitted, as you wrote, it is obtained first and then assembled into SQL

You can see that if your project is directly M or D function, you can directly pass the data (including GET, POST, and other column parameters) transmitted from the page, and then fill it in the where, if you create a separate model class based on the table, you need to add parameters in the public method, as shown below:

/**     * @todo get one news info     */    public function getOneNewsInfo($id){        $where = '`id` = \''.$id.'\'';        return $this->where($where)->select();    }

Otherwise, it will be called directly on the page:
$model = M('table'); $where = '`id` = \''.$id.'\'';        $model ->where($where)->select();

You can see that if your project is directly M or D function, you can directly pass the data (including GET, POST, and other column parameters) transmitted from the page, and then fill it in the where, if you create a separate model class based on the table, you need to add parameters in the public method, as shown below:

/**     * @todo get one news info     */    public function getOneNewsInfo($id){        $where = '`id` = \''.$id.'\'';        return $this->where($where)->select();    }

Otherwise, it will be called directly on the page:
$model = M('table'); $where = '`id` = \''.$id.'\'';        $model ->where($where)->select();






Well, I got the ID. The problem is that the content below does not change.

Public function index () {$ Data = M ('zhaopin'); // instantiate the Data object import ('org. util. page '); // import the paging class $ count = $ Data-> where ($ map)-> count (); // query the total number of records meeting the requirements $ Page = new Page ($ count, 20 ); // The total number of incoming records of the instantiated paging class $ nowPage = isset ($ _ GET ['P'])? $ _ GET ['P']: 1; $ adi = $ _ GET ['id']; $ list = $ Data-> where ($ map, "Position = '$ aid' and Recruitment = '$ aid'")-> order ('shijian desc, id asc ')-> page ($ nowPage. ','. $ Page-> listRows)-> select (); $ show = $ Page-> show (); // Display output by page $ this-> assign ('page ', $ show); // value-assigned paging output $ this-> assign ('list', $ list); // value-assigned dataset $ this-> display (); // output Template} -------------------------------------------------------- filter all
 
  
{$ Vo ['position']}
  
 
 
Region:
All Shenzhen {$ Vo ['recruitment ']}
------------------------------------------------------- The following is the content -------------------------------------------------------------------------------------
{$ Vo ['job'] | mb_substr = 0, 8, 'utf-8'} {$ vo ['company _ name']} {$ vo ['recruitment ']} {$ vo ['shijian']}
Recruitment: {$ vo ['hiring']} company Nature: {$ vo ['natural']} scale: {$ vo ['company _ scale']} years of experience: {$ vo ['work _ experience: {$ vo ['degree _ required']} monthly salary: {$ vo ['salary ']} RMB/month
Job requirements: {$ vo ['job _ requirements '] | mb_substr = 0,150, 'utf-8'}

Khan, there is no rule on how to pass this xxx file. this is a condition, and the condition is that you want to use it to limit the results you want. then I will ask you, why do you need these two fields for parallel filtering? why not all fields are filtered! Similarly, if you want to filter records whose Position is 111, it is $ Data-> where ("Position = '000000'")-> select (); as for this 111, if it is dynamically transmitted, as you wrote, it is obtained first and then assembled into SQL



Well, I got the ID. The problem is that the content below does not change.

Public function index () {$ Data = M ('zhaopin'); // instantiate the Data object import ('org. util. page '); // import the paging class $ count = $ Data-> where ($ map)-> count (); // query the total number of records meeting the requirements $ Page = new Page ($ count, 20 ); // The total number of incoming records of the instantiated paging class $ nowPage = isset ($ _ GET ['P'])? $ _ GET ['P']: 1; $ adi = $ _ GET ['id']; $ list = $ Data-> where ($ map, "Position = '$ aid' and Recruitment = '$ aid'")-> order ('shijian desc, id asc ')-> page ($ nowPage. ','. $ Page-> listRows)-> select (); $ show = $ Page-> show (); // Display output by page $ this-> assign ('page ', $ show); // value-assigned paging output $ this-> assign ('list', $ list); // value-assigned dataset $ this-> display (); // output Template} -------------------------------------------------------- filter all
 
  
{$ Vo ['position']}
  
 
 
Region:
All Shenzhen {$ Vo ['recruitment ']}
------------------------------------------------------- The following is the content -------------------------------------------------------------------------------------
{$ Vo ['job'] | mb_substr = 0, 8, 'utf-8'} {$ vo ['company _ name']} {$ vo ['recruitment ']} {$ vo ['shijian']}
Recruitment: {$ vo ['hiring']} company Nature: {$ vo ['natural']} scale: {$ vo ['company _ scale']} years of experience: {$ vo ['work _ experience: {$ vo ['degree _ required']} monthly salary: {$ vo ['salary ']} RMB/month
Job requirements: {$ vo ['job _ requirements '] | mb_substr = 0,150, 'utf-8'}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.