#!/usr/bin/php -q
<?php

// Copyright (c) 2012, Intorrent LLC, US. All rights Reserved.
//
// This software is the copyrighted work of Inroeewr, LLC.
// Use of the software is subject to the general business terms and conditions of Intorrent 
// and its related transaction documents like license sheets or other written notices.
//
// Any reproduction or redistribution of the software not in accordance with the license terms
// is expressly prohibited by law, and may result in severe civil and criminally penalties.
// Violators will be prosecuted to the maximum extent possible.

?>
<?php
  // this program ssupports a simple query along the lines of "select x from tab where y='val';

  include "/usr/local/astium/web/php/config.php";

  $cms = new DB_CMS;
 
  if (!empty($argv[1]) && !empty($argv[2])) {
	$tab = $argv[1];
	$field = $argv[2];
        $colnam = $argv[3];
        $colval = $argv[4];

	$q = "select $field from $tab where $colnam = '$colval'";

	$cms->query($q);

	while ($cms->next_record()) {
		$ret = $cms->f($field);
		echo $ret."\n";
                exit(0);
	}
  } else {
        echo "Please run:  get_db_val  <table name> <table column name> <where-field-name> <where-val>\n";
	exit(10);
  }

?>

