start sql select * where fieldName = true

A place for users and developers of the Xataface to discuss and receive support.

start sql select * where fieldName = true

Postby PolderBoy » Thu Aug 20, 2009 5:49 am

Dear all,

The main table has about 200.000 records at this moment but will go into the millions. The table has also a boolaen value which tells if record is active or not.
The user would like to see only the active records.

Can I set the major SQL statement?
And where?

Thanks,
Polderboy
PolderBoy
 
Posts: 72
Joined: Fri Apr 03, 2009 12:53 am

Postby shannah » Thu Aug 20, 2009 11:20 am

Best thing is to use a security filter. In your delegate class, define a method:
Code: Select all
init(&$table){
    $table->setSecurityFilter(array('active'=>1));
}


Assuming that the column you want to filter on is named 'active'
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

almost what the client wants

Postby PolderBoy » Fri Aug 21, 2009 4:01 am

Thanks it is working like a charm but when the user clicks the 'find' tab and searches for active = 0 then there are no records found.... And there are records.

So when possible it should be the start sql but when the users wants to find the other records it should be possible.

Thanks in advance,
Polderboy
PolderBoy
 
Posts: 72
Joined: Fri Apr 03, 2009 12:53 am

possible solution

Postby PolderBoy » Fri Aug 21, 2009 4:48 am

Me again.

I think I have found a solution:
I make a column in a table which holds a value: ShowAll YES or NO

Code: Select all
Function init(&$table)
{
      if ($record->val('ShowAll') == 'NO')
      {
          $table->setSecurityFilter(array('active'=>1));
       }
}

Would this work?
I will try anyway. Thanks for the answer.

PolderBoy
PolderBoy
 
Posts: 72
Joined: Fri Apr 03, 2009 12:53 am

This works.

Postby PolderBoy » Fri Aug 21, 2009 5:34 am

Code: Select all
   function init(&$table)
   {
      include("conf.php");
      
      $con = mysql_connect($host, $user, $password);
      
         if (!$con)
         {
            die('Could not connect: ' . mysql_error());
         }
      
      mysql_select_db($name, $con);
      
      $sql="SELECT ShowAll FROM ShowAll";
      
         $result = mysql_query($sql);
         $row = mysql_fetch_array($result);
         $ShowAll = $row['ShowAll'];
      
      mysql_close($con);

      
      if($ShowAll == 'NO')
      {
         $table->setSecurityFilter(array('GeExporteerd'=>'NEE'));
      }
   }
PolderBoy
 
Posts: 72
Joined: Fri Apr 03, 2009 12:53 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 19 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved