Example #1
0
	/**
	 * This will use a generic database descriptor like $this->dbKey
	 * to instantiate a PHPlib database.
	 *
	 * You shouldn't need to call this directly - it's typically called by
	 * {@link dbInit} to initialize $this->db.
	 *
	 * @param array $dbKey the database descriptor
	 * @return object ADOdb database instance or false on error
	 */
	function _doDbInit($dbKey=NULL)
	{
		if (!$dbKey)
			$dbKey = $this->dbKey;
		return LPC_DB::getConnection($dbKey);
	}
Example #2
0
$newEngine="InnoDB";

// Init DB connection
$db=LPC_DB::getConnection($dbKey);

// Get tables
$rs=$db->query("SHOW TABLES");
while(!$rs->EOF) {
	$table=$rs->fields[0];
	$rs->MoveNext();
	echo $table."... ";
	$rs2=$db->query("
		SELECT ENGINE
		FROM information_schema.TABLES
		WHERE
			TABLE_SCHEMA='".LPC_DB::getDatabaseName($dbKey)."' AND
			TABLE_NAME='".$table."'
	");
	if ($rs2->fields[0]==$newEngine) {
		echo "already ".$newEngine."\n";
		continue;
	}
	$rs2=$db->query("ALTER TABLE `".$table."` ENGINE=".$newEngine);
	if (!$rs2) {
		echo $db->ErrorMsg()."\n";
		continue;
	}
	echo "DONE\n";
}

echo "Clean exit.\n";
Example #3
0
	private function showHelp()
	{
		echo "Usage:\n";
		echo "php generate_classes.php <dbKey> <base class> [<path>]\n";
		echo "Where\n";
		echo "* dbKey is the name of a database key registered with LPC_DB.\n";
		echo "* base class is the name of the base class for this application.\n";
		echo "  For example POLL_Base, PROF_Base, BLOG_Base, etc.\n";
		echo "  If the base class doesn't exist it will also be created.\n";
		echo "* path is an optional parameter specifying where the classes should be written.\n";
		echo "  If left blank, the default path is used:\n";
		echo "  ".LPC_classes."\n";
		echo "\n";
		echo "Available database keys:\n";
		echo "* ".implode("\n* ", LPC_DB::listAvailableKeys())."\n";
	}