adamTablaPlugin
Ez a plugin csinálja meg a táblás CRUDot, amit bemutattam.Adam Szanto
**/
class adamTablaPlugin
{
var $tableObject;
function adamTablaPlugin ($arguments="")
{
$db = $arguments['db'];
$table = $arguments['table'];
$thisTable = new table($table,$db); // Instantiating New Table Object
$this->tableObject = $thisTable; // Setting table Object in Local variable
}
function generate()
{
$thisTable = $this->tableObject;
// The things you can get from $thisTable are
$thisHostName = $thisTable->getDatabaseHost(); // Database Server Address
$thisUserName = $thisTable->getDbUserName(); // Database UserName being used
$thisDbPassword = $thisTable->getDbPassword(); // User password used to access database
$thisDbName = $thisTable->getDatabase(); // Database connected to
$thisTableName = $thisTable->getTableName(); // Name of the table Selected
$thisTablesArray = $thisTable->getDbTables(); // All Tables in Database
$thisFieldNameArray = $thisTable->getFieldNameArray(); // Array with all fieldNames (Strings)
$thisFieldInfoArray = $thisTable->getFieldInfoArray(); // Array of Fields with all meta data (fieldInfo Objects)
$thisPrimaryKey = $thisTable->getPrimaryKey(); // Primary Key of the current table
//$code = "";
//$code .= "You are connected to : ".$thisHostName." \n";
//$code .= "You are connected as : ".$thisUserName."
\n";
if (isset($_POST['tabla_field'])) { //<
$mezok=$_POST['tabla_field'];
$recname=substr($thisTableName,0,-1);
$q='show fields from '.$thisTableName;
$mezok_r=mysql_query($q) or print(mysql_error());
$mezo_data=array();
while ($mezo_elem=mysql_fetch_array($mezok_r))
$mezo_data[$mezo_elem['Field']]=$mezo_elem['Type'];
$code=' $a) //<
$code.=$mezo.', ';
$code=substr($code, 0, -2).') VALUES (';
foreach ($mezok as $mezo => $a) //<
$code.=get_code_of($recname, $mezo_data, $mezo).", ";
$code=substr($code, 0, -2).")';\n mysql_query(\$q) or print(mysql_error());\n\n".
' break;'."\n".' case "edit":'."\n";
$elso_mezohoz=array_keys($mezok);
$code.=' if (isset($_POST['."'".$recname."_".strtolower($elso_mezohoz[0])."'".'])) {'."\n".
" \$q='UPDATE ".$thisTableName." SET ";
foreach ($mezok as $mezo => $a) //<
$code.=$mezo.'='.get_code_of($recname, $mezo_data, $mezo).', ';
$code=substr($code, 0, -2)." WHERE ID='.\$_GET['id'];\n mysql_query(\$q) or print(mysql_error());\n".
' } else {'."\n".' $q='."'SELECT ";
$osszes=array();
for ($a=0;$a\n\n".''."\n";
$code.="
";
foreach ($mezok as $mezo => $value_ami_egyaltalan_nem_kell_senkinek_sem) //<
$code.="\n
".$mezo."
";
$code.="\n
Szerkeszt
\n".
"
Töröl
\n\n";
$code.="';
foreach($mezok as $mezo => $a) //<
$code.='