PHP Classes

Dynamic query with defaultcols giving strange results

Recommend this page to a friend!

      DrasticTools  >  All threads  >  Dynamic query with defaultcols...  >  (Un) Subscribe thread alerts  
Subject:Dynamic query with defaultcols...
Summary:Need further explanation of using defaultcolsContainExpression
Author:Terry Wysocki
Date:2012-12-21 18:37:29

  1. Dynamic query with defaultcols...   Reply   Report abuse  
Terry Wysocki - 2012-12-21 18:37:29
Like a lot of other posts in this forum, I'm trying to use drasticGrid whereby I can create a WHERE clause for the mysql query dynamically. I tried subclassing but that doesn't work when dynamically generated.
I can find no documentation on how to use defaultcolsContainExpression which has some promise. I'm finding some strange behavior though. First of all, it doesn't seem to matter what the first element is of each array condition, even a garbage string of characters, but some thing must be there (EXCEPT in the case below where a substring is being used and the fieldname can be blank???).

In the two examples below I'm trying to use the variable $category in the filter, but with no success:

$category = 'automotive';

$selcond = array(
"something" => "category > '" .$category. "'",
"anything" => "publish = 1",
"" => "SUBSTRING(merchant_name,1,1) >='M'"

$selcond = array(
"something" => "category = 'automotive'",
"anything" => "publish = 1",
"" => "SUBSTRING(merchant_name,1,1) >='M'"

include (PATHDRASTICTOOLS . "Examplemysqlconfig.php");
include (PATHDRASTICTOOLS . "drasticSrcMySQL.class.php");
$options = array(
"add_allowed" => false,
"delete_allowed" => false,
"defaultcolsContainExpression" => true,
"defaultcols" => $selcond,
"editablecols" => array("coupon_code","item_title","description_1","publish","is_featured")
$src = new drasticSrcMySQL($server, $user, $pw, $db, $table, $options);

Even though I'm not using GET it still ignores the $category part of the condition. A print_r($options) shows identical output in both cases. So why doesn't the first one work? And am I using defaultcolsContainExpression as intended?