issue about SQL select

issue about SQL select

webprophetswebprophets Posts: 18Questions: 5Answers: 0

I wanna get data from table like below SQL ( only get specific day data)

"SELECT * FROM 'table' where media_type = 'facebook' AND DATE_FORMAT(FROM_UNIXTIME(time),'%Y-%m-%d') = DATE_FORMAT('" . $time . "','%Y-%m-%d');"

I know that where() function can do the where clause , but how to do the " DATE_FORMAT(FROM_UNIXTIME(time),'%Y-%m-%d') = DATE_FORMAT('" . $time . "','%Y-%m-%d')"?

If I have to modify the code, let me know where to explore it?

My idea way is using Editor client-server data (http://editor.datatables.net/manual/server) to address this issue. But it is weird that I can not get cell id , I check the id[] is "", if I set idSrc:"id", (id is the id column on database table), if I trace the send request parameter, it is there like id[]="222", but I still can not get it from server end using $_POST['id'] or $_GET['id']?

This question has an accepted answers - jump to answer

Answers

  • webprophetswebprophets Posts: 18Questions: 5Answers: 0

    Hi Allen

    I have not find any clue from document, but after I had a look the source code,
    I found this code fix the issue
    ->where("DATE_FORMAT(time,'%Y-%m-%d')",$time)

    From your document, I didn't aware that I can pass whole code to the first parameter. I was thinking the first parameter just the "key". But it works! (Maybe I just miss some document)

    anyway, wish this helps other people meet similar issue.

    =========================
    But I have question, for the SQL "LIKE" clause or other advanced search , how Editor deal with them?
    Is there any "Query()" method can query the whole sql sentence to solve the issue straightforward ?

    or which way I can modify the code to make it work?

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Hi,

    Yes, in the case of where you can pass in functions as the first parameter - but that is about the only place you can do so in the Editor libraries.

    But I have question, for the SQL "LIKE" clause or other advanced search , how Editor deal with them?

    The optional third parameter for where() can be used to specify the operator:

    where( 'user', 'allan%', 'like' )

    would be the equivalent of user like = 'allan%'.

    Allan

This discussion has been closed.