예제 #1
0
파일: App.php 프로젝트: jstanden/portsensor
 static function getFields()
 {
     return SearchFields_Translation::getFields();
 }
예제 #2
0
파일: DAO.php 프로젝트: jstanden/devblocks
 public static function getSearchQueryComponents($columns, $params, $sortBy = null, $sortAsc = null)
 {
     $fields = SearchFields_Translation::getFields();
     // Sanitize
     if (!isset($fields[$sortBy]) || '*' == substr($sortBy, 0, 1)) {
         $sortBy = null;
     }
     list($tables, $wheres) = parent::_parseSearchParams($params, array(), $fields, $sortBy);
     $select_sql = sprintf("SELECT " . "tl.id as %s, " . "tl.string_id as %s, " . "tl.lang_code as %s, " . "tl.string_default as %s, " . "tl.string_override as %s ", SearchFields_Translation::ID, SearchFields_Translation::STRING_ID, SearchFields_Translation::LANG_CODE, SearchFields_Translation::STRING_DEFAULT, SearchFields_Translation::STRING_OVERRIDE);
     $join_sql = "FROM translation tl ";
     //			"LEFT JOIN contact_org o ON (o.id=a.contact_org_id) "
     // [JAS]: Dynamic table joins
     //			(isset($tables['o']) ? "LEFT JOIN contact_org o ON (o.id=a.contact_org_id)" : " ").
     //			(isset($tables['mc']) ? "INNER JOIN message_content mc ON (mc.message_id=m.id)" : " ").
     $where_sql = "" . (!empty($wheres) ? sprintf("WHERE %s ", implode(' AND ', $wheres)) : "WHERE 1 ");
     $sort_sql = !empty($sortBy) ? sprintf("ORDER BY %s %s ", $sortBy, $sortAsc || is_null($sortAsc) ? "ASC" : "DESC") : " ";
     $result = array('primary_table' => 'translation', 'select' => $select_sql, 'join' => $join_sql, 'where' => $where_sql, 'has_multiple_values' => $has_multiple_values, 'sort' => $sort_sql);
     return $result;
 }
예제 #3
0
파일: DAO.php 프로젝트: Hildy/devblocks
 /**
  * Enter description here...
  *
  * @param DevblocksSearchCriteria[] $params
  * @param integer $limit
  * @param integer $page
  * @param string $sortBy
  * @param boolean $sortAsc
  * @param boolean $withCounts
  * @return array
  */
 static function search($params, $limit = 10, $page = 0, $sortBy = null, $sortAsc = null, $withCounts = true)
 {
     $db = DevblocksPlatform::getDatabaseService();
     $fields = SearchFields_Translation::getFields();
     // Sanitize
     if (!isset($fields[$sortBy])) {
         $sortBy = null;
     }
     list($tables, $wheres) = parent::_parseSearchParams($params, array(), $fields, $sortBy);
     $start = $page * $limit;
     // [JAS]: 1-based [TODO] clean up + document
     $select_sql = sprintf("SELECT " . "tl.id as %s, " . "tl.string_id as %s, " . "tl.lang_code as %s, " . "tl.string_default as %s, " . "tl.string_override as %s ", SearchFields_Translation::ID, SearchFields_Translation::STRING_ID, SearchFields_Translation::LANG_CODE, SearchFields_Translation::STRING_DEFAULT, SearchFields_Translation::STRING_OVERRIDE);
     $join_sql = "FROM translation tl ";
     //			"LEFT JOIN contact_org o ON (o.id=a.contact_org_id) "
     // [JAS]: Dynamic table joins
     //			(isset($tables['o']) ? "LEFT JOIN contact_org o ON (o.id=a.contact_org_id)" : " ").
     //			(isset($tables['mc']) ? "INNER JOIN message_content mc ON (mc.message_id=m.id)" : " ").
     $where_sql = "" . (!empty($wheres) ? sprintf("WHERE %s ", implode(' AND ', $wheres)) : "");
     $sql = $select_sql . $join_sql . $where_sql . (!empty($sortBy) ? sprintf("ORDER BY %s %s", $sortBy, $sortAsc || is_null($sortAsc) ? "ASC" : "DESC") : "");
     $rs = $db->SelectLimit($sql, $limit, $start);
     /* @var $rs ADORecordSet */
     $results = array();
     if (is_a($rs, 'ADORecordSet')) {
         while (!$rs->EOF) {
             $result = array();
             foreach ($rs->fields as $f => $v) {
                 $result[$f] = $v;
             }
             $id = intval($rs->fields[SearchFields_Translation::ID]);
             $results[$id] = $result;
             $rs->MoveNext();
         }
     }
     // [JAS]: Count all
     $total = -1;
     if ($withCounts) {
         $count_sql = "SELECT count(*) " . $join_sql . $where_sql;
         $total = $db->GetOne($count_sql);
     }
     return array($results, $total);
 }