FK DDL Regeneration for MySQL

<?php
mysql_connect(‘localhost:3307′,’root’,’slopoc’); /* set with your mysql database configuration */
$the_schema = ‘mhs_job_scheduler’; /* set with your database schema */
function get_table_rec($schema){
/* low query
mysql_select_db(‘information_schema’);
$query = “select distinct table_name from table_constraints where constraint_schema = ‘”.$schema.’” AND  constraint_type = ‘FOREIGN KEY’ “;
*/
mysql_select_db($schema);
$query = “show tables”;
return mysql_query($query);
}
echo “<table border=1> <tr> <td colspan=3> FK DDL Regeneration of <b> $the_schema </b> Schema </td> </tr>”;
$res_table_fk = get_table_rec($the_schema);
$i = 1;
while ($rec_table_fk = mysql_fetch_array($res_table_fk)){
$table_fk = $the_schema.’.’.$rec_table_fk[0];
echo “<tr> <td> <b> $i </b> </td> <td colspan=2> <b> $table_fk </td> </td> </tr>”;
$query = “show create table $table_fk”;
$res = mysql_query($query);
while ($rec = mysql_fetch_array($res)){
echo “<tr> <td> </td> <td> DDL of $rec[0] Table </td> <td> $rec[1] </td> </tr>”;
$pos = strpos($rec[1],’FOREIGN KEY’);
if ($pos > 0){
$left = substr($rec[1],0,$pos);
$right = substr($rec[1],$pos,strlen($rec[1])-$pos);
$left_rev = strrev($left);
$pos_cons = strpos($left_rev,’TNIARTSNOC’);
$pos_coma = strpos($left_rev,’,');
$cons = substr($left,$pos-$pos_coma,$pos_coma);
$ddl_cons = $cons .’ ‘.substr($right,0,strlen($right)-(strlen($right)-strpos($right,’ENGINE’)));
$ddl_cons = ‘ALTER TABLE `’.$table_fk.’` ADD ‘.$ddl_cons.’;';
echo “<tr> <td> </td> <td> FK DDL </td> <td> <font color=BLUE> $ddl_cons </font> </td> </tr>”;
} else {
echo “<tr> <td> </td> <td> FK DDL </td> <td> <font color=RED> NO FK </font> </td> </tr>”;
}
}
$i++;
}
echo “</table>”;
?>

<?php

mysql_connect(‘localhost:3307′,’root’,’slopoc’); /* set with your mysql database configuration */

$the_schema = ‘mhs_job_scheduler’; /* set with your database schema */

function get_table_rec($schema){

/* low query

mysql_select_db(‘information_schema’);

$query = “select distinct table_name from table_constraints where constraint_schema = ‘”.$schema.’” AND  constraint_type = ‘FOREIGN KEY’ “;

*/

mysql_select_db($schema);

$query = “show tables”;

return mysql_query($query);

}

echo “<table border=1> <tr> <td colspan=3> FK DDL Regeneration of <b> $the_schema </b> Schema </td> </tr>”;

$res_table_fk = get_table_rec($the_schema);

$i = 1;

while ($rec_table_fk = mysql_fetch_array($res_table_fk)){

$table_fk = $the_schema.’.’.$rec_table_fk[0];

echo “<tr> <td> <b> $i </b> </td> <td colspan=2> <b> $table_fk </td> </td> </tr>”;

$query = “show create table $table_fk”;

$res = mysql_query($query);

while ($rec = mysql_fetch_array($res)){

echo “<tr> <td> </td> <td> DDL of $rec[0] Table </td> <td> $rec[1] </td> </tr>”;

$pos = strpos($rec[1],’FOREIGN KEY’);

if ($pos > 0){

$left = substr($rec[1],0,$pos);

$right = substr($rec[1],$pos,strlen($rec[1])-$pos);

$left_rev = strrev($left);

$pos_cons = strpos($left_rev,’TNIARTSNOC’);

$pos_coma = strpos($left_rev,’,');

$cons = substr($left,$pos-$pos_coma,$pos_coma);

$ddl_cons = $cons .’ ‘.substr($right,0,strlen($right)-(strlen($right)-strpos($right,’ENGINE’)));

$ddl_cons = ‘ALTER TABLE `’.$table_fk.’` ADD ‘.$ddl_cons.’;';

echo “<tr> <td> </td> <td> FK DDL </td> <td> <font color=BLUE> $ddl_cons </font> </td> </tr>”;

} else {

echo “<tr> <td> </td> <td> FK DDL </td> <td> <font color=RED> NO FK </font> </td> </tr>”;

}

}

$i++;

}

echo “</table>”;

?>

download disini

Posted in PHP. 1 Comment »

New Relaease: qoSikel 1.0 Alfa

 qoSikel 1.0 Alfa is a Web-Desktop Information System for Controlling “Government Village” Management.  It based on PHP as web server language and ExtJS (http://extjs.com) as web client language. It use Oracle and MySQL as the database. qoSikel also support Charting with “flash charting method”.qoSikel use qWikiOffice (http://qwikioffice.com) as the framework.

RoadMap:

Ver. 1.0  Alfa: [ 21 Mey 2009]

  • Report Viewer support for Charting with “flash charting method”
  • Support for Oracle & MySQL

Ver 1.o Beta: [on progress...]

  • Add printting modul with Jasper Report
  • Add export modul (Excell)

Screen Shot:

qoSikel 1.0 alfa

qoSikel 1.0 alfa

SAK W3 Version: Progress RoadMap(2009.1)

Development Progress for: Sistem Administrasi Kependudukan Web Version

SAK W3 Progress RoadMap (2009.1)

SAK W3 Progress RoadMap (2009.1)

RoadMap (2009.1):

Template:

  • Front End Template (85%)
  • Login Template (100%)
  • Back End Template (95%)

Read the rest of this entry »

Coming soon! Sistem Administrasi Kependudukan (SAK) W3 Version!

In development process: Sistem Administrasi Kependudukan (SAK) Web Version!

SAK Front End Interface

SAK Front End Interface

Road Map (2009)

  • Add Front End Interface
  • Add Back End Interface
  • Add Back End Anonymous/Quest User
  • Add Graphical Report
  • Add Akta Report
  • Add More Future…

Read the rest of this entry »

Elxis, CMS yang powerfull dan X-database

Sekarang ini banyak CMS (Content Management System) yang telah beredar dan mempunyai “pengsa pasarnya” sendiri. Hal ini disebabkan kemudahan yang disediakan oleh CMS.

Di antara CMS yang paling populer di indonesia adalah: Joomla, sudah banyak institusi baik pemerintahan, pendidikan, perusahaan, yayasan, komunitas maupun web-site pribadi (blog) yang telah menggunakan Joomla. Joomla adalah turunan dari Mambo, lalu apakah anda tahu ada turunan Mambo selain Joomla? Read the rest of this entry »

MHSCore Logo

MHSCore Logo

MHSCore Logo

Berfikir tentang logo yang akan saya pake untuk produk-produk saya. Tapi kelihatannya belum mewakili. :D . Pantang menyerah dan terus desain! Merdeka!

Thinking about logo for my product. But i think it’s not yet linked with my product. :D . Keep Design and Never give up!

News: Still in development! “Administrasi Kartu Pencari Kerja”

news:Still in development!  "Administrasi Kartu Pencari Kerja"

News: Still in development!

New Release: CAPIL (Akta Catatan Sipil)

CAPIL (Akta Catatan Sipil)

CAPIL (Akta Catatan Sipil)

Aplikasi untuk Kantor Catatan Sipil. Khususnya untuk Administrasi Akta: Akta Kelahiran; Akta Pernikahan; Akta Perceraian; Akta Kematian; Akta Pengakuan.

Fitur: Read the rest of this entry »

New Release: SIMGAJI Alfa Testing

SIMGAJI

SIMGAJI

New Release: Job Scheduler (Task Script Scheduler)

Job Scheduler (Task Script Scheduler)
Feature:
- Running Task/Job/Script Schedule formated by:

  • Date
  • Time
  • Day
  • Month
  • Year
  • Custom

- Compressed Result file (.rar)
- Sending Result file to FTP Server
- Monitoring Result File from http web server

Example of script:
- Backup oracle db every year, month, day, hour or minutes
- Backup mysql db every day