MysqliDb::where PHP Method

where() public method

This method allows you to specify multiple (method chaining optional) AND WHERE statements for SQL queries.
public where ( string $whereProp, mixed $whereValue = 'DBNULL', string $operator = '=', string $cond = 'AND' ) : MysqliDb
$whereProp string The name of the database field.
$whereValue mixed The value of the database field.
$operator string Comparison operator. Default is =
$cond string Condition of where statement (OR, AND)
return MysqliDb
    public function where($whereProp, $whereValue = 'DBNULL', $operator = '=', $cond = 'AND')
    {
        // forkaround for an old operation api
        if (is_array($whereValue) && ($key = key($whereValue)) != "0") {
            $operator = $key;
            $whereValue = $whereValue[$key];
        }
        if (count($this->_where) == 0) {
            $cond = '';
        }
        $this->_where[] = array($cond, $whereProp, $operator, $whereValue);
        return $this;
    }

Usage Example

コード例 #1
2
/**
 * @description Elimina una comentario
 * @param $comentario_id
 */
function removeComentario($comentario_id)
{
    validateRol(0);
    $db = new MysqliDb();
    $db->where("comentario_id", $comentario_id);
    $results = $db->delete('posts_comentarios');
    if ($results) {
        echo json_encode(1);
    } else {
        echo json_encode(-1);
    }
}
All Usage Examples Of MysqliDb::where