Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Application Development » $where clause problem with list1 and read
$where clause problem with list1 and read [message #1543] Wed, 13 August 2008 06:24 Go to next message
bonzo_bcn is currently offline  bonzo_bcn
Messages: 152
Registered: June 2008
Senior Member
In one of my classes I have this proc:
 function _cm_initialise ($where, $selection){
	if ($GLOBALS['mode'] == 'search' || $GLOBALS['mode'] == 'list') {
	
		require_once 'classes/entidad.class.inc';
		$entidad = new entidad;       
	        $entidad->sql_select = 'entidad_id';
		$entidad_id = $entidad->getData("entidad_id='" .$_SESSION['role_id'] ."'");
		
		if ($entidad->numrows == 1){
			if (empty($where)){
	    		    $where = "participante_id IN (SELECT participante_id FROM part_ent_xref WHERE entidad_id=" .$entidad_id[0]['entidad_id'] . ")";
			}else{
			    $where .= "AND participante_id IN (SELECT participante_id FROM part_ent_xref WHERE entidad_id=" .$entidad_id[0]['entidad_id'] . ")";
			}
	    }
	}
		
	return $where;
}


The problem I have with it, is that when I hit the read button of a list1 transacation, even though nothing is selected it opens all the records instead of showing the message 'Nothing has been selected yet.'

[Updated on: Wed, 13 August 2008 07:05]

Report message to a moderator

Re: $where clause problem with list1 and add1 [message #1544 is a reply to message #1543] Wed, 13 August 2008 06:58 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
There is no 'read' button in the ADD1 pattern, so your description is confusing.

Re: $where clause problem with list1 and read [message #1545 is a reply to message #1543] Wed, 13 August 2008 07:05 Go to previous messageGo to next message
bonzo_bcn is currently offline  bonzo_bcn
Messages: 152
Registered: June 2008
Senior Member
Sorry, edited. (I meant read instead of add1)
Re: $where clause problem with list1 and read [message #1546 is a reply to message #1545] Wed, 13 August 2008 07:21 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
What $where string is being generated?

What happens when you run the same query directly through MySQL?


Re: $where clause problem with list1 and read [message #1549 is a reply to message #1543] Wed, 13 August 2008 12:01 Go to previous messageGo to next message
bonzo_bcn is currently offline  bonzo_bcn
Messages: 152
Registered: June 2008
Senior Member
This is what I got in the debugger:
 ***** /ceae/participante(enq1).php 2008-08-13 15:02:57
SELECT SQL_CALC_FOUND_ROWS participante.* FROM participante  WHERE participante.tippart='E' AND participante.participante_id IN (SELECT participante_id FROM part_ent_xref WHERE entidad_id=3)     LIMIT 1 OFFSET 0 =>Count=2

 ***** /ceae/participante(enq1).php 2008-08-13 15:04:06
SELECT SQL_CALC_FOUND_ROWS participante.* FROM participante  WHERE ( participante.participante_id='30' )     LIMIT 1 OFFSET 0 =>Count=1



The first one is when I haven't selected any records (but all are openes when I hit 'read').
The second one is when I select one record and click 'read'.
Re: $where clause problem with list1 and read [message #1551 is a reply to message #1549] Thu, 14 August 2008 08:16 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
Is that the query from the LIST1 or the ENQUIRE1 task?

The only reason that an ENQUIRE1 would fail would be if the $where clause did not contain values for the table's primary key, so what does $where contain and what is the primary key?


Re: $where clause problem with list1 and read [message #1553 is a reply to message #1543] Thu, 14 August 2008 09:35 Go to previous messageGo to next message
bonzo_bcn is currently offline  bonzo_bcn
Messages: 152
Registered: June 2008
Senior Member
that is from the enquire task button.
the primary key is participante_id.
It's not that it fails, it's that it opens all the records of list1 despite I didn't select any.

If I select a record and click 'read' it opens that single record, but if I don't select any record and I hit 'read', then it opens all the records of list1.
Re: $where clause problem with list1 and read [message #1554 is a reply to message #1553] Thu, 14 August 2008 10:02 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
This should not be happening. The ENQUIRE1 task should terminate with an error if the $where string does not contain values for the primary key. That is what line 64 in std.enquire1.inc means when it says
// check that primary key is complete
$dbobject->checkPrimaryKey = true;
You will have to step through with your debugger to see what is being passed in the $where string and what is happening to it.


Re: $where clause problem with list1 and read [message #1558 is a reply to message #1554] Mon, 18 August 2008 11:20 Go to previous message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
I found a bug in the 'isPkeyComplete()' function where the primary key was not supplied but it returned TRUE because an additional unique key had been defined, even though no values for that unique key were present. See attached file for an updated script.

Previous Topic: Problem with two list1 transactions on one table
Next Topic: How can I achieve retrieving data from different tables and marking them as printed?
Goto Forum:
  


Current Time: Wed Nov 27 05:35:06 EST 2024

Total time taken to generate the page: 0.03075 seconds