< Back to Code

Radius - A centralized business management platform I conceptualized, developed, coded, produced and upgraded while V.P. Digital Research and Development at TMPG in White Plains, NY.

Its core purpose was to create more efficient workflows for us and over 2000 radio stations across the U.S. and Canada when submitting quotes for media inventory (known as "Avails" in the industry).

Radius transformed our culture at TMPG and improved relationships with our media vendors by greatly streamlining Avail proposal negotiations (formally concluded via manual activity and non-centralized workflows).

Code:

  • CSS3 / Bootstrap
  • HTML 5 / jQuery / JSON / AJAX / JavaScript
  • PHP ( +PDO extension )
  • MySQL

Radius - 1 minute quick glance - main capabilities:

Radius Application (preview 1m 17s)

PHP Class example

The below code is an example of a basic (but often used) Radius class that accepts an array of parameters, e.g. proposal information from a vendor (while logged into Radius) and inserts them into the MySQL Database.

The $db object passed into function InsertArray() is the database connection using the PHP Data Objects (PDO) extension that defines a lightweight, consistent interface for accessing databases in PHP.

  • The $table and $array_vars variables are appropriately sanitized for security before the InsertRadiusArray Class is called.
  • Using bound parameter methods within the PDO extention further mitigates risk of SQL injection when accessing the database.
  • For more sophisticated examples, please contact me: rich@richcarthew.com

<?php
//DB conn above WWW ROOT level
require_once('../../../xxxxdb_connection.php'); //PDO Objects


Class InsertRadiusArray{

	function InsertArray($db, $table, $array_vars){

		//create sql string with all $vars
		foreach ($array_vars as $key => $val){
		    $columns[]= $key;
		    $vals [] = ':'.$key;
		    $updates[] = "$key = :$key";
		}
		$column = implode(', ', $columns);
		$values = implode(', ', $vals);
		$update = implode(', ', $updates);

		try {
			$sql = "INSERT INTO $table ($column)
					VALUES ($values) ON DUPLICATE KEY UPDATE $update";
			$statement = $db->prepare($sql);

			//pass bound parameters in as an array
			$statement->execute($array_vars);
		} //end try2 statement
		catch (PDOException $e)
		{
			// get names of keys and then output second key
			// name to track what insert data failed.
			$keys = array_keys($array_vars);
		    $err_msg = $e->getMessage();

			/*
			 then write to /error_log_datetime_file.txt
			'Error: '. $array_vars[0] . ' ' . $keys[1]. $err_msg. $datetime;
			*/
		}
	}
}

// ... Classes continue ...

?>

< Back to Code