Adding Your Own Custom Auto Queries

You can add your own auto queries (the Auto Tab in the left category pane) using either phpmyadmin or a custom php script.

The auto queries are stored in a table called <prefix>queries (replace the <prefix> with your database table prefix (this is set in config.php and by default it is dompunch_).

You simply need to fill the name and the query fields. Please see the screen-shot below (using phpmyadmin to add an auto query).

Custom Auto Queries

You can use [domains] and [catconn] in the queries and the application will automatically add the table prefix. This will not happen for other tables, so if your query includes any other table, you will have to use the full table name.

Here are some sample Queries

List Domains That Don't Belong to Any Category

FROM [domains] a LEFT JOIN [catconn] b ON a.sid = b.sid WHERE b.sid IS null

List all COM Domains That Belong to a Specific Category

FROM [domains] a LEFT JOIN [catconn] b ON a.sid = b.sid WHERE b.CategoryID IN (SELECT CategoryID FROM dompunch_catlist WHERE CategoryName='Business Domains') AND a.domain LIKE '%.com'

Remember to replace dompunch_catlist in the SQL above with your actual table name (if your table prefix is not dompunch_).

Sample PHP Script

Here is a sample PHP script that adds an auto-query. You have to copy and paste the code below to a text file with .php extension, edit and save to the lib/php/ folder. Then execute the script from your browser.

<?php
require_once("config.check.php");
require_once("../../config.php");
require_once("base.php");

error_reporting(E_ALL);
connect_to_mysql_and_select_db();

$sql = "INSERT INTO `dompunch_queries` (`id`, `Name`, `Description`, `Query`) VALUES (NULL, 'Uncategorized Domains', NULL, 'FROM dompunch_domains a LEFT JOIN dompunch_catconn b ON a.sid = b.sid WHERE b.sid IS null')";

mysql_query( $sql ) or die("Couldn't execute your query.".mysql_error());
?>