예제 #1
0
        /// <summary>条件查询文章分类 </summary>
        /// <param name="parent_id">父亲ID</param>
        /// <returns>ArticleClassCollection 包含条件查询的记录.</returns>
        public static ArticleClassCollection GetListByParentID(int parent_id)
        {
            ArticleClassCollection tempList = new ArticleClassCollection();
            string sql;

            MySqlParameter[] parms = null;

            if(parent_id > 0)
            {
                sql = "SELECT * FROM t_articleclass WHERE parent_id = ?parent_id ORDER BY ac_order, ac_id";
                parms = new MySqlParameter[] { new MySqlParameter("?parent_id", MySqlDbType.Int32)};
                parms[0].Value = parent_id;
            }
            else
            {
                sql = "SELECT * FROM t_articleclass WHERE parent_id IS NULL ORDER BY ac_order, ac_id";
            }

            MySqlDataReader myReader = DbHelper.ExecuteDataReader(sql, parms);

            if (myReader.HasRows)
            {
                tempList = new ArticleClassCollection();
                while (myReader.Read())
                {
                    tempList.Add(FillDataRecord(myReader));
                }
            }
            myReader.Close();

            return tempList;
        }
예제 #2
0
        /// <summary>查询文章分类 所有数据</summary>
        /// <returns>ArticleClassCollection 包含所有记录.</returns>
        public static ArticleClassCollection GetList()
        {
            ArticleClassCollection tempList = new ArticleClassCollection();
            string sql = "SELECT * FROM t_articleclass";

            MySqlDataReader myReader = DbHelper.ExecuteDataReader(sql);

            if (myReader.HasRows)
            {
                tempList = new ArticleClassCollection();
                while (myReader.Read())
                {
                    tempList.Add(FillDataRecord(myReader));
                }
            }
            myReader.Close();

            return tempList;
        }