Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

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.

Updating a query:

 

Code Block Example
//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.

  

//Create our query object
$query = new Query(Config::$ANALYTICS_ANALYST);

This line will simply create the $query object, using the analyst credentials from the the Config.class.php file.

 

//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);

Delete the query, remembering to pass in the correct QueryID.

$queryId (string)

This is the QueryID 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:

 

Code Block Example
/* --- Method 1: Find the QueryID in the return array after saving a query --- */
//save query, returns object with unique Query ID
$res = $query->save($name, $type, $params);

//find the queryID
$queryId = $res["_id"];


/* --- Method 2: query all saved queries and choose the appropriate QueryID --- */
//Alternately, you can use $query->get() to return all saved queries
$res = $query->get();
           
//find the QueryID
$queryId = $res[0]["_id"];

 

Return:

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

Return
//If delete was successful 
 
1
 
//If delete was unsuccessful
 
 

 

 

  • No labels