Compare commits
2 Commits
63330d5fc0
...
e445c2bda1
Author | SHA1 | Date | |
---|---|---|---|
|
e445c2bda1 | ||
|
f5349db697 |
29
DBchat.cs
29
DBchat.cs
@ -14,8 +14,9 @@ namespace NeDvachAPI
|
|||||||
public static Post[] DbList()
|
public static Post[] DbList()
|
||||||
{
|
{
|
||||||
// Build connection string using parameters from portal
|
// Build connection string using parameters from portal
|
||||||
Post[] posts = new Post[10];
|
//Post[] posts = new Post[10];
|
||||||
int postCount = 0;
|
List<Post> posts = new List<Post>();
|
||||||
|
//int postCount = 0;
|
||||||
string received = "";
|
string received = "";
|
||||||
string connString =
|
string connString =
|
||||||
String.Format(
|
String.Format(
|
||||||
@ -33,13 +34,22 @@ namespace NeDvachAPI
|
|||||||
conn.Open();
|
conn.Open();
|
||||||
|
|
||||||
|
|
||||||
using (var command = new NpgsqlCommand(@"
|
// using ( var command = new NpgsqlCommand(@"
|
||||||
|
// SELECT * FROM
|
||||||
|
// (SELECT post_id, substring(post,1,200)
|
||||||
|
// FROM dvach
|
||||||
|
// ORDER BY post_id DESC
|
||||||
|
// limit 10
|
||||||
|
// )
|
||||||
|
subquery ORDER BY post_id ASC", conn) )
|
||||||
|
using ( var command = new NpgsqlCommand(@"
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
(SELECT post_id, substring(post,1,200)
|
(
|
||||||
|
SELECT post_id, post
|
||||||
FROM dvach
|
FROM dvach
|
||||||
ORDER BY post_id
|
ORDER BY post_id DESC
|
||||||
DESC limit 10)
|
) subquery
|
||||||
subquery ORDER BY post_id ASC", conn))
|
ORDER BY post_id ASC", conn) )
|
||||||
{
|
{
|
||||||
|
|
||||||
var reader = command.ExecuteReader();
|
var reader = command.ExecuteReader();
|
||||||
@ -58,8 +68,9 @@ namespace NeDvachAPI
|
|||||||
Id = reader.GetInt32(0),
|
Id = reader.GetInt32(0),
|
||||||
Text = reader.GetString(1)
|
Text = reader.GetString(1)
|
||||||
};
|
};
|
||||||
posts[postCount] = receivedPost;
|
posts.Add(receivedPost);
|
||||||
postCount++;
|
//posts[postCount] = receivedPost;
|
||||||
|
//postCount++;
|
||||||
}
|
}
|
||||||
reader.Close();
|
reader.Close();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user