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 29 entries

# ID Order no Order date Customer name Order amount Order status Actions
1 41 76778 2016-09-08 Deacon Tyson 77 Pending
2 42 66729 2016-09-08 Dawn Potter 90 Completed
3 45 40334 2016-09-08 Connor Marquez 87 Completed
4 46 30771 2016-09-08 Gillian Kirk 461 Completed
5 47 96349 2016-09-08 Wallace Gillespie 71 Completed
6 49 3691 2016-09-08 Callum Solomon 75 Completed
7 51 37429 2016-09-08 Talon Rowland 77 Completed
8 53 62391 2016-09-08 Bree Gaines 96 Completed
9 56 409 2016-09-08 Jasper Santiago 68 Completed
10 60 74815 2016-09-08 Caleb Lynn 95 Completed
# ID Order no Order date Customer name Order amount Order status Actions