DataTables warning: table id=schedule_socialmedia - SQLSTATE[42S22]: Column not found: 1054 Unknown

DataTables warning: table id=schedule_socialmedia - SQLSTATE[42S22]: Column not found: 1054 Unknown

webprophetswebprophets Posts: 18Questions: 5Answers: 0
edited December 2014 in Editor

Hi Allen

Sorry about opening a new thread since I closed last one as below, but this is a new issue.
http://datatables.net/forums/discussion/25049/issue-about-sql-select

Editor where() working fine with single SQL where condition
But when I trying to make two conditions like SQL below, where() function is not quite right. ( I have read API and trying to use array as parameter, but still failed)

SQL:

select ...... from ..... where DATE_FORMAT(time,'%Y\-%m\-%d') = "2014-12-12" AND media_type = "facebook"

the code I am using:

            ->where( array("DATE_FORMAT(time,'%Y\-%m\-%d')", "media_type"), array("2014-12-12","facebook") )

for single condition as below, it is working.

   ->where("DATE_FORMAT(time,'%Y\-%m\-%d')",$time)

I also try this , but not working as well

$key =    array("message","media_type");
$value = array("today weathere","facebook");
$op=array("=","=");

->where( $key,$value,$op)

based on your document on line 360

http://editor.datatables.net/docs/current/php/source-class-DataTables.Editor.html#356

conditions to use: where( array('fieldName', ...), array('value', ...) );

don know why it is not working.

This question has an accepted answers - jump to answer

Answers

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

    You should be able to simply call the where() method twice and it will add the queries together automatically with AND:

    ->where("DATE_FORMAT(time,'%Y\-%m\-%d')",$time)
    ->where( 'media_type', 'facebook' )
    

    Allan

  • webprophetswebprophets Posts: 18Questions: 5Answers: 0

    Yes I read other thread to find out this.
    But I just wondering know what's the array in parameter used for?
    where( array('fieldName', ...), array('value', ...) );

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

    Could you point me to where in the documentation it says that an array can be used for the Editor class's where() method. It shouldn't (and doesn't in the API docs).

    Thanks,
    Allan

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    edited December 2014

    Allan: it's in the comment block for the where() method.

    http://editor.datatables.net/docs/current/php/source-class-DataTables.Editor.html#356

    At least you know somebody reads the comments....

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

    Got it - thanks! That comment is nonsense. I'm going to package up a new beta of Editor 1.4 today, and I'll get this sorted out for that.

    Thanks for flagging it up!

    Allan

This discussion has been closed.