Example #1
0
 /**
  * посчитать количество через sql
  * (с параметрами Load())
  */
 function count_sql()
 {
     $sql = $this->build_sql(true);
     $res = $this->db->query($sql);
     $row = $this->db->fetch_row($res);
     $this->db->free_result($res);
     return @intval($row['s_count']);
 }
Example #2
0
 /**
  * Called when new item creates
  * Calc position for item and set it
  */
 private function assign_position()
 {
     $sql_tail = '';
     if (!$this->container->with_positions()) {
         return;
     }
     $pos = $this->field('position');
     if (isset($pos['space'])) {
         $sql_tail = ' WHERE ' . $this->make_space_sql($pos['space']);
     }
     $sql = "SELECT max(position) as mp FROM " . $this->get_table() . $sql_tail;
     $row = $this->db->fetch_row($res = $this->db->query($sql));
     $this->db->free_result($res);
     $this->position = (int) $row['mp'] + 1;
 }