コード例 #1
0
    /**
     * Get the notification type id from the name
     *
     * @param string $notification_type_name The name
     * @return int the notification_type_id
     * @throws \src\notification\exception
     */
    public function get_notification_type_id($notification_type_name)
    {
        $notification_type_ids = $this->cache->get('notification_type_ids');
        if ($notification_type_ids === false) {
            $notification_type_ids = array();
            $sql = 'SELECT notification_type_id, notification_type_name
				FROM ' . $this->notification_types_table;
            $result = $this->db->sql_query($sql);
            while ($row = $this->db->sql_fetchrow($result)) {
                $notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id'];
            }
            $this->db->sql_freeresult($result);
            $this->cache->put('notification_type_ids', $notification_type_ids);
        }
        if (!isset($notification_type_ids[$notification_type_name])) {
            if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name])) {
                throw new \src\notification\exception($this->user->lang('NOTIFICATION_TYPE_NOT_EXIST', $notification_type_name));
            }
            $sql = 'INSERT INTO ' . $this->notification_types_table . ' ' . $this->db->sql_build_array('INSERT', array('notification_type_name' => $notification_type_name, 'notification_type_enabled' => 1));
            $this->db->sql_query($sql);
            $notification_type_ids[$notification_type_name] = (int) $this->db->sql_nextid();
            $this->cache->put('notification_type_ids', $notification_type_ids);
        }
        return $notification_type_ids[$notification_type_name];
    }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function insert(array $additional_data)
 {
     $item_data = $this->reset_nestedset_values($additional_data);
     $sql = 'INSERT INTO ' . $this->table_name . ' ' . $this->db->sql_build_array('INSERT', $item_data);
     $this->db->sql_query($sql);
     $item_data[$this->column_item_id] = (int) $this->db->sql_nextid();
     return array_merge($item_data, $this->add_item_to_nestedset($item_data[$this->column_item_id]));
 }
コード例 #3
0
ファイル: acp_styles.php プロジェクト: AkhilSharma/Serbest
    /**
     * Install style
     *
     * @param array $style style data
     * @return int Style id
     */
    protected function install_style($style)
    {
        // Generate row
        $sql_ary = array();
        foreach ($style as $key => $value) {
            if ($key != 'style_id' && substr($key, 0, 1) != '_') {
                $sql_ary[$key] = $value;
            }
        }
        // Add to database
        $this->db->sql_transaction('begin');
        $sql = 'INSERT INTO ' . STYLES_TABLE . '
			' . $this->db->sql_build_array('INSERT', $sql_ary);
        $this->db->sql_query($sql);
        $id = $this->db->sql_nextid();
        $this->db->sql_transaction('commit');
        add_log('admin', 'LOG_STYLE_ADD', $sql_ary['style_name']);
        return $id;
    }