Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] PHP-MySQLi-Database-Class
lekosm2
post 29.08.2017, 13:33:19
Post #1





Grupa: Zarejestrowani
Postów: 141
Pomógł: 0
Dołączył: 9.10.2015

Ostrzeżenie: (0%)
-----


Cześć, w skrypcie używam tej classy https://github.com/joshcam/PHP-MySQLi-Datab...ss#select-query

Moje zapytanie wygląda tak:
  1. $posts = $db->get('posts');

Wyświetla wszystkie posty, a chciałbym by je jeszcze sortowało według daty, data posta jest zapisywana w timesamp, a kolumna z datą to "post_date", jak bedzie wyglądać zapytanie z sortowaniem według daty?
Go to the top of the page
+Quote Post
nospor
post 29.08.2017, 14:02:59
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




W linku co sam tu podales masz
Cytat
More advanced examples:

$params = Array(1, 'admin');
$users = $db->rawQuery("SELECT id, firstName, lastName FROM users WHERE id = ? AND login = ?", $params);
print_r($users); // contains Array of returned rows

// will handle any SQL query
$params = Array(10, 1, 10, 11, 2, 10);
$q = "(
SELECT a FROM t1
WHERE a = ? AND B = ?
ORDER BY a LIMIT ?
) UNION (
SELECT a FROM t2
WHERE a = ? AND B = ?
ORDER BY a LIMIT ?
)";
$resutls = $db->rawQuery ($q, $params);
print_r ($results); // contains Array of returned rows


edit::

o orderBy juz nie wspominajac....
Cytat
Ordering method

$db->orderBy("id","asc");
$db->orderBy("login","Desc");
$db->orderBy("RAND ()");
$results = $db->get('users');

Wszystko to nastronie do ktorej sam podales linka...


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.07.2025 - 17:35