Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

It may be necessary to delete a query. In order to do so you will need to know the unique QueryID for the query to be deleted.

...

Code Block
languagephp
themeRDark
firstline1
titleCode Block Example
linenumberstrue
//Include the analytics class and the configuration class
$t->runInteraction("Analytics.class.php");
$t->runInteraction("Config.class.php");
 
//Create our query object
$query = new Query(Config::$ANALYTICS_ANALYST);

//Read all saved queries
$res = $query->get();

//find the queryID for the query that you need to delete
$queryId = $res[0]["_id"]; 
	
//delete the query, 
//remembering to pass in the QueryID to delete that query
$response = $query->delete($queryId);


Explanation:

The first two "runInteraction" lines will simply "include" the class files you already uploaded. Make sure your have used the correct interaction names. You will need to put both of these lines on any page, or interaction, that you will be calling the class.

  

...

:

...

 

//Read all saved queries
$res = $query->get();

This line will will read all saved queries (there are no search options available).

 

//find the queryID for the query that you need to update
$queryId = $res[0]["_id"];

 Each query has a unique id, you will need to know the ID of the query that you need to delete.

 

//delete the query, remembering to pass in the queryId for the query to deleted 
$response = $query->delete($queryId);

...

$queryId (string)

This is the QueryID Query ID of the query you wish to delete. Your QueryID will have been returned (in the return object) when you first saved the query. You can also find the correct QueryID by using $query->get() to return all saved queries.

Example:

 

...

languagephp
themeRDark
firstline1
titleCode Block Example
linenumberstrue

...

 
Please see List (Read) Saved Queries for more information

 

 

Return:

If the delete was successful the response would be TRUE. If you try to delete a query that does not exist, 

...