GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
DBIx::Custom::Where(3) User Contributed Perl Documentation DBIx::Custom::Where(3)

DBIx::Custom::Where - Where clause

  # Create DBIx::Custom::Where object
  my $where = $dbi->where;
  
  # Clause
  $where->clause(['and', 'title like :title', 'price = :price']);
  $where->clause(['and', ':title{like}', ':price{=}']);
  
  # Stringify where clause
  my $where_clause = "$where";
  my $where_clause = $where->to_string;
    # -> where title like :title and price = :price
  
  # Only price condition
  $where->clause(['and', ':title{like}', ':price{=}']);
  $where->param({price => 1900});
    # -> where price = :price
  
  # Only title condition
  $where->clause(['and', ':title{like}', ':price{=}']);
  $where->param({title => 'Perl'});
    # -> where title like :title
  
  # Nothing
  $where->clause(['and', ':title{like}', ':price{=}']);
  $where->param({});
    # => Nothing
  
  # or condition
  $where->clause(['or', ':title{like}', ':price{=}']);
    # -> where title = :title or price like :price
  
  # More than one parameter
  $where->clause(['and', ':price{>}', ':price{<}']);
  $where->param({price => [1000, 2000]});
    # -> where price > :price and price < :price
  
  # Only first condition
  $where->clause(['and', ':price{>}', ':price{<}']);
  $where->param({price => [1000, $dbi->not_exists]});
    # -> where price > :price
  
  # Only second condition
  $where->clause(['and', ':price{>}', ':price{<}']);
  $where->param({price => [$dbi->not_exists, 2000]});
    # -> where price < :price
  
  # More complex condition
  $where->clause(
    [
      'and',
      ':price{=}',
      ['or', ':title{=}', ':title{=}', ':title{=}']
    ]
  );
    # -> pirce = :price and (title = :title or title = :title or tilte = :title)
  
  # Using Full-qualified column name
  $where->clause(['and', ':book.title{like}', ':book.price{=}']);
    # -> book.title like :book.title and book.price = :book.price

  my $clause = $where->clause;
  $where = $where->clause(
    ['and',
      ':title{=}', 
      ['or', ':date{<}', ':date{>}']
    ]
  );

Where clause. Above one is expanded to the following SQL by to_string If all parameter names is exists.

  where title = :title and ( date < :date or date > :date )

  my $param = $where->param;
  $where = $where->param({
    title => 'Perl',
    date => ['2010-11-11', '2011-03-05'],
  });

  my $dbi = $where->dbi;
  $where = $where->dbi($dbi);

DBIx::Custom object.

  my $join = $where->join;
  $join = $where->join($join);

join information. This values is addd to select method "join" option values.

  $where->join(['left join author on book.author = authro.id']);

DBIx::Custom::Where inherits all methods from Object::Simple and implements the following new ones.

  $where->to_string;

Convert where clause to string.

double quote is override to execute "to_string" method.

  my $string_where = "$where";
2017-03-29 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.