/** * Add / Update Data information * * @return void * @author **/ public static function setData($input) { $Category = $input['id'] == NULL || !isset($input['id']) ? new Content() : Content::find($input['id']); $tableCol = DB::query('show columns from ' . Content::$table); foreach ($tableCol as $value) { $fieldname = $value->field; if (stristr($value->field, 'name')) { $Category->{$fieldname} = $input['data']; } elseif (stristr($value->field, 'desc')) { $Category->{$fieldname} = $input['description']; } } $Category->save(); $action = $input['id'] == NULL || !isset($input['id']) ? 'Insert' : '<b>(' . $input['id'] . ')</b> Update'; Log::write('Data', 'Data <b>' . $input['data'] . '</b> ' . $action . ' by ' . Auth::user()->username); }
/** * Check Existing table * * @return void * @author **/ public static function checkTable($table, $field) { $existTable = DB::query("show tables like '" . $table . "'"); $tableCol = DB::query("show columns from " . $table . " like '" . $field . "'"); return !empty($existTable) && !empty($tableCol) ? true : false; }