Exemplo n.º 1
0
 function obtainValues(\SimplOn\Elements\Element &$element, $query_string)
 {
     $values = array();
     foreach ($element->processData('doSearch') as $dataInfo) {
         foreach ($dataInfo as $fieldInfo) {
             $bindable_values = array(':' . $fieldInfo[0] => $fieldInfo[2], ':RLLIKE__' . $fieldInfo[0] => '%' . $fieldInfo[2] . '%', ':LLIKE__' . $fieldInfo[0] => '%' . $fieldInfo[2], ':RLIKE__' . $fieldInfo[0] => $fieldInfo[2] . '%');
             foreach ($bindable_values as $label => $value) {
                 if (strpos($query_string, $label) !== false) {
                     $values[$label] = $value;
                 }
             }
         }
     }
     return $values;
 }
Exemplo n.º 2
0
 function countElements(\SimplOn\Elements\Element &$element, $group = null)
 {
     if (isset($group)) {
         $group = implode(',', $group);
     }
     $storages = is_array($element->storage()) ? $element->storage() : array($element->getClass() => $element->storage());
     foreach ($element->processData('doRead') as $dataInfo) {
         foreach ($dataInfo as $fieldInfo) {
             $fields[] = $fieldInfo[0];
         }
     }
     foreach ($storages as $class => $storage) {
         $storage_fields = $fields;
         $addFields = '"' . strtr($class, array('\\' => '\\\\')) . '" as `SimplOn_class`, ' . '"' . $element->field_id() . '" as `SimplOn_field_id`, ' . '"' . $element->field_id() . '" as `SimplOn_id`, ' . '"' . $element->field_id() . '", ';
         $where = $this->filterCriteria($element);
         $selects[] = '(SELECT ' . $addFields . implode(', ', $storage_fields) . ' FROM ' . $storage . ' ' . ($where ? 'WHERE ' . $where : '') . ' ' . ($group ? 'GROUP BY ' . $group : '') . ')';
     }
     $query_string = implode("\n" . ' UNION ', $selects) . 'ORDER BY SimplOn_id desc';
     $query = $this->db->prepare($query_string);
     $values = $this->obtainValues($element, $query_string);
     $query->execute($values);
     $results = $query->fetchAll();
     $totalRecords = sizeof($results);
     return $totalRecords;
 }