0

SQL ステートメントで Order By を作成するにはどうすればよいですか? 私はすでにこのようなステートメントで試しましたが、これはうまくいきません。実行するたびにクラッシュします。$_GET['email'] が原因ですか? 私は何を間違っていますか?

$results = $this->EE->db->query(
"SELECT ct.*, t.*, em.*, cd.*
FROM transactions as t
Inner JOIN exp_channel_titles as ct on (t.restaurant_id = ct.entry_id)
Inner JOIN exp_channel_data as cd on (ct.entry_id = cd.entry_id)
inner join exp_members as em on (t.cardid-10000000 = em.member_id) 
WHERE ct.title = '".$_GET['email']."'ORDER BY t.created DESC");
4

3 に答える 3

0

コメントに示されているように、 の前に 1 つのスペースがありません'ORDER BY'でした。

から

WHERE ct.title = '".$_GET['email']."'ORDER BY t.created DESC");
                                   ^^^

WHERE ct.title = '".$_GET['email']." 'ORDER BY t.created DESC");
                                   ^^^^

すべて一緒に:

$results = $this->EE->db->query(
"SELECT ct.*, t.*, em.*, cd.*
FROM transactions as t
Inner JOIN exp_channel_titles as ct on (t.restaurant_id = ct.entry_id)
Inner JOIN exp_channel_data as cd on (ct.entry_id = cd.entry_id)
inner join exp_members as em on (t.cardid-10000000 = em.member_id) 
WHERE ct.title = '".$_GET['email']." 'ORDER BY t.created DESC");
于 2013-02-26T12:22:05.867 に答える
0

べきである:

$results = $this->EE->db->query(
"SELECT ct.*, t.*, em.*, cd.*
FROM transactions as t
Inner JOIN exp_channel_titles as ct on (t.restaurant_id = ct.entry_id)
Inner JOIN exp_channel_data as cd on (ct.entry_id = cd.entry_id)
inner join exp_members as em on (t.cardid-10000000 = em.member_id) 
WHERE ct.title = '".$_GET['email']."' ORDER BY t.created DESC");

$_GET['email']と の間にスペースがありませんORDER BY

于 2013-02-26T12:20:59.640 に答える
0

読みやすくするために、個別の変数を使用します。

$email  =   $_GET['email'];

$query  =   "SELECT
              ct.*,
              t.*,
              em.*,
              cd.*
            FROM transactions as t
              Inner JOIN exp_channel_titles as ct
                on (t.restaurant_id = ct.entry_id)
              Inner JOIN exp_channel_data as cd
                on (ct.entry_id = cd.entry_id)
              inner join exp_members as em
                on (t.cardid - 10000000 = em.member_id)
            WHERE ct.title = '$email'
            ORDER BY t.created DESC";

$results = $this->EE->db->query($query);
于 2013-02-26T12:40:40.503 に答える