In this Article, i am trying to make a model file (php ) for table called user_table.
file will be save in table_name.php
<?php
public function create_model($dataSet=""){
$table_name=$dataSet['table'];
$str_open='<?php $'.$table_name.' = ' ;
$get_table_info=array();
//$str.='$'.$table_name.'=array(';
$table_info=new general;
$get_table_info=$table_info->get_table_schema($table_name); // fetch table column from database
$str_close=' ?>';
$new_model_file_name=__DIR__.'/../model/'.$table_name.'.php';
try{
$done=file_put_contents($new_model_file_name, $str_open.' '.var_export($get_table_info, true).'; return $'.$table_name.'; '.$str_close);
//echo 'Model <b>'.$table_name.'</b> has been created';
echo 'done';
}
catch(Exception $e){
echo 'oops there is some error to write new model';
}
/*
$b=include_once($new_model_file_name);
echo '<pre>';
print_r($b);
echo '</pre>';*/
}
?>
<?php
public function create_model($dataSet=""){
$table_name=$dataSet['table'];
$str_open='<?php $'.$table_name.' = ' ;
$get_table_info=array();
//$str.='$'.$table_name.'=array(';
$table_info=new general;
$get_table_info=$table_info->get_table_schema($table_name); // fetch table column from database
$str_close=' ?>';
$new_model_file_name=__DIR__.'/../model/'.$table_name.'.php';
try{
$done=file_put_contents($new_model_file_name, $str_open.' '.var_export($get_table_info, true).'; return $'.$table_name.'; '.$str_close);
//echo 'Model <b>'.$table_name.'</b> has been created';
echo 'done';
}
catch(Exception $e){
echo 'oops there is some error to write new model';
}
/*
$b=include_once($new_model_file_name);
echo '<pre>';
print_r($b);
echo '</pre>';*/
}
?>
No comments:
Post a Comment