public static function getPhpNameMap() { if (self::$phpNameMap === null) { $map = CatalogWriterPeer::getTableMap(); $columns = $map->getColumns(); $nameMap = array(); foreach ($columns as $column) { $nameMap[$column->getPhpName()] = $column->getColumnName(); } self::$phpNameMap = $nameMap; } return self::$phpNameMap; }
public function filterPerSource($c, $filters) { $filters_key = array_keys($filters); foreach ($filters_key as $key) { $value = $filters[$key]; if ($value == '' || $value == null) { continue; } if ($key == 'writer_id') { $c->addJoin(VCatalogPerSourcePeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(CatalogWriterPeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogWriterPeer::getTableMap()->getColumn('WRITER_ID'); } elseif ($key == 'code') { $c->addJoin(VCatalogPerSourcePeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogPeer::getTableMap()->getColumn('CODE'); } elseif ($key == 'title') { $c->addJoin(VCatalogPerSourcePeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogPeer::getTableMap()->getColumn('TITLE'); } elseif ($key == 'writer') { $c->addJoin(VCatalogPerSourcePeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(CatalogWriterPeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(WriterPeer::ID, CatalogWriterPeer::WRITER_ID); $column = WriterPeer::getTableMap()->getColumn('NAME'); } elseif ($key == 'publisher') { $c->addJoin(VCatalogPerSourcePeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(PublisherPeer::ID, CatalogPeer::PUBLISHER_ID); $column = PublisherPeer::getTableMap()->getColumn('NAME'); } elseif ($key == 'cat_category_id') { $c->addJoin(VCatalogPerSourcePeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogPeer::getTableMap()->getColumn('CAT_CATEGORY_ID'); } elseif ($key == 'publisher_id') { $c->addJoin(VCatalogPerSourcePeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogPeer::getTableMap()->getColumn('PUBLISHER_ID'); } elseif ($key == 'YEAR_ADDED') { $column = VCatalogPerSourcePeer::getTableMap()->getColumn('YEAR_ADDED'); #$c->addJoin(VCatalogPerSourcePeer::CATALOG_ID, ColItemPeer::CATALOG_ID); #$c->addJoin(ColItemPeer::CATALOG_ID, CatalogPeer::ID); #$column = ColItemPeer::getTableMap()->getColumn('YEAR_ADDED'); } elseif ($key == 'department_id') { # if ($filters[$key] == 1) { $c->addJoin(VCatalogPerSourcePeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(DepartmentPeer::ID, VCatalogPerSourcePeer::DEPARTMENT_ID); $column = DepartmentPeer::getTableMap()->getColumn('ID'); # } else { # $c->addJoin(VCatalogPerSourcePeer::CATALOG_ID, CatalogPeer::ID); # $c->addJoin(DepartmentPeer::ID, VCatalogPerSourcePeer::DEPARTMENT_ID); # $c->addJoin(VDepartmentPeer::ID, DepartmentPeer::PARENT); # $column = VDepartmentPeer::getTableMap()->getColumn('ID'); # } } else { $column = VCatalogPerSourcePeer::getTableMap()->getColumn($key); } $name = $column->getFullyQualifiedName(); $creoleType = $column->getCreoleType(); if ($creoleType == CreoleTypes::TIMESTAMP) { $from = $value['from']; $to = $value['to']; if ($from != '' && $from != null) { $c->add($name, $from, Criteria::GREATER_EQUAL); } if ($to != '' && $to != null) { $c->add($name, $to, Criteria::LESS_EQUAL); } } else { if ($creoleType == CreoleTypes::INTEGER || $creoleType == CreoleTypes::BIGINT) { $c->add($name, $value, Criteria::EQUAL); } else { if ($creoleType == CreoleTypes::VARCHAR) { $c->add($name, "%{$value}%", Criteria::LIKE); } else { if ($creoleType == CreoleTypes::NUMERIC) { $c->add($name, $value, Criteria::EQUAL); } } } } } }
public function filter($c, $filters) { $filters_key = array_keys($filters); foreach ($filters_key as $key) { $value = $filters[$key]; if ($value == '' || $value == null) { continue; } if ($key == 'writer_id') { $c->addJoin(CatalogWriterPeer::CATALOG_ID, CatalogPeer::ID); $column = CatalogWriterPeer::getTableMap()->getColumn('WRITER_ID'); } elseif ($key == 'copies') { $c->addJoin(VCatalogPeer::CATALOG_ID, CatalogPeer::ID); $column = VCatalogPeer::getTableMap()->getColumn('COPIES'); } elseif ($key == 'writer') { $c->addJoin(CatalogWriterPeer::CATALOG_ID, CatalogPeer::ID); $c->addJoin(WriterPeer::ID, CatalogWriterPeer::WRITER_ID); $column = WriterPeer::getTableMap()->getColumn('NAME'); } elseif ($key == 'publisher') { $c->addJoin(PublisherPeer::ID, CatalogPeer::PUBLISHER_ID); $column = PublisherPeer::getTableMap()->getColumn('NAME'); } elseif ($key == 'title') { $column = CatalogPeer::getTableMap()->getColumn('TITLE'); } else { $column = CatalogPeer::getTableMap()->getColumn($key); } $name = $column->getFullyQualifiedName(); $creoleType = $column->getCreoleType(); if ($creoleType == CreoleTypes::TIMESTAMP) { $from = $value['from']; $to = $value['to']; if ($from != '' && $from != null) { $c->add($name, $from, Criteria::GREATER_EQUAL); } if ($to != '' && $to != null) { $c->add($name, $to, Criteria::LESS_EQUAL); } } else { if ($creoleType == CreoleTypes::INTEGER || $creoleType == CreoleTypes::BIGINT) { $c->add($name, $value, Criteria::EQUAL); } else { if ($creoleType == CreoleTypes::VARCHAR) { $c->add($name, "%{$value}%", Criteria::LIKE); } } } } }