# HstoreExpression.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2009 by Sergey S. Sergeev                               *
    00004  *                                                                         *
    00005  *   This program is free software; you can redistribute it and/or modify  *
    00006  *   it under the terms of the GNU Lesser General Public License as        *
    00007  *   published by the Free Software Foundation; either version 3 of the    *
    00008  *   License, or (at your option) any later version.                       *
    00009  *                                                                         *
    00010  ***************************************************************************/
    00011
    00016     final class HstoreExpression extends StaticFactory
    00017     {
    00018         const CONTAIN       = '?';
    00019         const GET_VALUE     = '->';
    00020         const LEFT_CONTAIN  = '@>';
    00021         const CONCAT        = '||';
    00022
    00026         public static function containKey($field, $key)
    00027         {
    00028             return new BinaryExpression($field, $key, self::CONTAIN);
    00029         }
    00030
    00034         public static function getValueByKey($field, $key)
    00035         {
    00036             return new BinaryExpression($field, $key, self::GET_VALUE);
    00037         }
    00038
    00042         public static function containValue($field, $key, $value)
    00043         {
    00044             return new BinaryExpression($field, "{$key}=>{$value}", self::LEFT_CONTAIN);
    00045         }
    00046
    00050         public static function concat($field, $value)
    00051         {
    00052             return new BinaryExpression($field, $value, self::CONCAT);
    00053         }
    00054
    00058         public static function containHstore($field, Hstore $hstore)
    00059         {
    00060             return new BinaryExpression($field, $hstore->toString(), self::LEFT_CONTAIN);
    00061         }
    00062
    00063         public static function containValueList($field, array $list)
    00064         {
    00065             return
    00066                 self::containHstore(
    00067                     $field,
    00068                     Hstore::make($list)
    00069                 );
    00070         }
    00071     }
    00072 ?>