Where condition Apply Where conditions in crud (improved in v 4.2)

You can add where condition to filter records using where() function. In simplest term, you can pass the column name and value to apply where condition, default "=" (equalto) operator will be used if you don't pass any operator as third parameter

Below example shows how to generate queries like WHERE `order_date` > ? AND `order_amount` >= ? AND ( `order_status` = ? OR `order_status` = ? )

  
                            $pdocrud = new PDOCrud();
                            /**
                            * Add where condition
                            * @param   string   $colName                          column name for which where condition to be applied
                            * @param   string   $val                              value of column
                            * @param   string   $operator                         any operator like =, !=, default value is "="
                            * @param   string   $andOroperator                    whether to use "and" or "or" operator, if empty, default andOrOperator = "and" will be used
                            * @param   string   $bracket                          whether to use opening "(" or closing bracket ")", leave empty if not required
                            * return   object                                     Object of class
                            */
                            $pdocrud->where("order_date", "2015-09-08", ">");
                            $pdocrud->where("order_amount", 50, ">=");
                            $pdocrud->where("order_status", "Completed", "=", "" ,"(");
                            $pdocrud->where("order_status", "Pending", "=", "OR" ,")");
                            echo $pdocrud->dbTable("orders")->render();
                        

Orders

Showing 1 to 10 of 18 entries

# ID Order no Order date Customer name Order amount Order status Actions
1 69 9552 2016-09-08 Xenos Clarke 89 Completed
2 71 91617 2016-09-08 Xenos Clarke 57 Completed
3 72 78062 2016-09-08 dsdsds 56 Completed
4 73 87594 2016-09-08 77 Completed
5 74 24386 2016-09-08 70 Completed
6 80 74040 2016-09-08 Penelope Moss 59 Completed
7 81 89592 2016-09-08 Chase Andrews 76 Completed
8 83 91414 2016-09-08 Kelly Garcia 91 Completed
9 88 43892 2016-09-08 Avye Fowler 55 Completed
10 91 5518 2016-09-08 Lynn Turner 64 Completed
# ID Order no Order date Customer name Order amount Order status Actions