Exemplo n.º 1
0
 public function testAddCategoryAsTopLevelCategoryCreatesLinker()
 {
     $mapper = $this->getMapper();
     $mapper->addCategory(null, 6);
     $select = new \Zend\Db\Sql\Select('catalog_category_website');
     $select->where(array('category_id' => 6));
     $testMapper = $this->getTestMapper();
     $result = $testMapper->query($select);
     $this->assertTrue(is_array($result));
 }
Exemplo n.º 2
0
 public function testAddOptionCreatesLinker()
 {
     $choiceId = $this->insertChoice(1);
     $optionId = $this->insertOption();
     $mapper = $this->getMapper();
     $mapper->addOption($choiceId, $optionId);
     $select = new \Zend\Db\Sql\Select('catalog_choice_option');
     $select->where(array('option_id' => $optionId, 'choice_id' => $choiceId));
     $testMapper = $this->getTestMapper();
     $result = $testMapper->query($select);
     $this->assertTrue(is_array($result));
 }
Exemplo n.º 3
0
 public function testSortOptionsChangesOrderOfOptions()
 {
     $table = 'catalog_product_option';
     $productId = 1;
     $linker1 = array('product_id' => $productId, 'option_id' => 3, 'sort_weight' => 0);
     $linker2 = array('product_id' => $productId, 'option_id' => 4, 'sort_weight' => 1);
     $testMapper = $this->getTestMapper();
     $testMapper->insert($linker1, $table);
     $testMapper->insert($linker2, $table);
     $order = array(4, 3);
     $mapper = $this->getMapper();
     $mapper->sortOptions($productId, $order);
     $select = new \Zend\Db\Sql\Select($table);
     $select->where(array('option_id' => 4, 'sort_weight' => 0));
     $result = $testMapper->query($select);
     $this->assertTrue(is_array($result));
 }
Exemplo n.º 4
0
 public function testSortChoicesChangesOrderOfChoices()
 {
     $optionId = 1;
     $choice1 = array('option_id' => $optionId, 'sort_weight' => 0);
     $choice2 = array('option_id' => $optionId, 'sort_weight' => 1);
     $testMapper = $this->getTestMapper();
     $choiceId1 = $testMapper->insert($choice1, 'catalog_choice')->getGeneratedValue();
     $choiceId2 = $testMapper->insert($choice2, 'catalog_choice')->getGeneratedValue();
     $order = array($choiceId2, $choiceId1);
     $mapper = $this->getMapper();
     $mapper->sortChoices($optionId, $order);
     $select = new \Zend\Db\Sql\Select('catalog_choice');
     $select->where(array('choice_id' => $choiceId2));
     $result = $testMapper->query($select);
     $this->assertTrue(is_array($result));
     $this->assertTrue($result['sort_weight'] == 0);
 }
Exemplo n.º 5
0
 public function fetchAll($where = '', $order = '', $limit = '', $paginated = '')
 {
     if ($paginated) {
         $select = new \Zend\Db\Sql\Select('hwi_product');
         if (is_array($where)) {
             $select->where($where);
         }
         if (is_array($order)) {
             foreach ($order as $key => $value) {
                 $select->order($value);
             }
         }
         $rs = new \Zend\Db\ResultSet\ResultSet();
         $rs->setArrayObjectPrototype(new product());
         $pageAdapter = new \Zend\Paginator\Adapter\DbSelect($select, $this->tableGateway->getAdapter(), $rs);
         $paginator = new \Zend\Paginator\Paginator($pageAdapter);
         return $paginator;
     }
     $resultSet = $this->tableGateway->select($where, $order, $limit);
     return $resultSet;
 }
<?php

/** @var $adapter Zend\Db\Adapter\Adapter */
$adapter = (include file_exists('bootstrap.php') ? 'bootstrap.php' : 'bootstrap.dist.php');
refresh_data($adapter);
$where = new Zend\Db\Sql\Where();
$where->equalTo('id', 1)->OR->equalTo('id', 2);
$where->OR->NEST->like('name', 'Ralph%')->OR->greaterThanOrEqualTo('age', 30)->AND->lessThanOrEqualTo('age', 50)->UNNEST->literal('foo = ?', 'bar');
$target = <<<EOS
SELECT "foo".* FROM "foo" WHERE "id" = '1' OR "id" = '2' OR ("name" LIKE 'Ralph%' OR "age" >= '30' AND "age" <= '50') AND foo = 'bar'
EOS;
$select = new Zend\Db\Sql\Select('foo');
$select->where($where);
assert_example_works($target == $select->getSqlString());
Exemplo n.º 7
0
 public static function ListaWhere($nazwaSlownika, $kolumna, $wartosc)
 {
     $projectTable = new TableGateway($nazwaSlownika, \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::getStaticAdapter());
     $select = new \Zend\Db\Sql\Select($nazwaSlownika);
     $where = new Where();
     $where->equalTo($kolumna, $wartosc);
     $select->where($where);
     $rowset = $projectTable->selectWith($select);
     if ($rowset) {
         return $rowset->current();
     }
     return array();
 }