Kamis, 17 Oktober 2019

MEMBUAT CRUD FILE (SOUND) DENGAN GROCERY CRUD DI CODEIGNITER

1.Langkah awal download terlebih dahulu File Framework CodeIgniter nya di


2. Selanjutnya download file plugins Grocery Crud di https://www.grocerycrud.com/


3.Satukan file CodeIgniter dengan Grocery Crud dalam satu folder yang sama


4.Buat database dengan nama db_crud_sound pada phpMyAdmin

Jalankan SQL dibawah ini di phpMyAdmin untuk membuat tabel pada database yaitu tb_sound



 CREATE TABLE IF NOT EXISTS `tb_sound` (
  `ID` char(10) NOT NULL,
  `FileName` varchar(50) NOT NULL,
  `FileType` varchar(50) NOT NULL,
  `FileExt` varchar(50) NOT NULL,
  `FileGroup` varchar(50) NOT NULL,
  `FileContent` varchar(50) NOT NULL,
  `FileDesc` varchar(50) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;



5.Selanjutnya masuk ke dalam folder Assets > Uploads dan buat folder baru dengan nama sound


6.Setelah membuat folder selanjutnya buat Controller pada folder application > controllers ,beri nama file Controller nya dengan nama Main.php dan isi dari file nya sebagai berikut



 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Main extends CI_Controller {
 public function __construct()
 {
  parent::__construct();
  $this->load->database();
  $this->load->helper('url');
  $this->load->library('grocery_CRUD');
 }
 public function sound()
 {
  $crud = new grocery_CRUD();
  $crud->set_table('tb_sound');
  $crud->set_subject('File suara');
  $crud->set_field_upload('FileContent','assets/uploads/sound');
  $output = $crud->render();
  $this->_example_output($output);
 }
 public function _example_output($output = null)
 {
  $this->load->view('example.php', $output);
 }
}

Sekarang cek hasil nya dengan menjalankan url : localhost/{folder-root}/{class}/{method}

Apabila tidak ada kesalahan akan tampil seperti berikut


7.Oke, sekarang saat nya mencoba menyimpan file suaranya


8.Setelah berhasil tersimpan coba klik file suaranya


9.Dan suara Ayam nya akan berjalan secara otomatis


10.Untuk melihat file suara tersimpan atau tidak, lihat folder assets > uploads > sound



Tes aplikasi anda dengan mengupload file di atas 5 MB. Jika upload anda gagal, cobalah tutorial di bawah ini 


Buka file grocery_crud.php pada folder application/config


Ganti kode:

$config['grocery_crud_file_upload_max_file_size'] = '20MB';

Menjadi

$config['grocery_crud_file_upload_max_file_size'] = '200MB';




Mengubah Upload File Size pada php.ini

 1. Buka XAMPP Control Setting


2. Klik pada tombol Config dan pilih php.ini



3. Pada file php.ini cari upload_max_filesize


 4. Ubah ukurannya sesuai dengan kebutuhan


5. Setelah itu restart kembali XAMPP nya



6. Selesai




Rabu, 02 Oktober 2019

CRUD Menggunakan CodeIgniter dan Grocery CRUD

Pertama Unduh terlebih dahulu Framework CodeIgniter dan GrocyCRUD









Exkstrak file CodeIgniter dan grocery crud


 Setelah itu file yang ada di dalam codeigniter copy kan kedalam file htdocs



replace file yang ada di codeigniter tadi dengan file yang dengan file yang ada di grocerycrud, kecuali


selanjutnya buat database dengan mengetikan localhost/phpmyadmin
buat database dengan nama db_multimedia seperti dibawah



setelah itu konfigurasi database CI, default username"root" dan database isi dengan nama database di phpmyadmin tadi.




Buat sebuah controllers baru dengan nama Core.php isinya seperti di atas




panggil url tersebut dengan url yang berada di dalam gambar 



buat sebuah table dengan nama employees dengan isinya :

CREATE TABLE IF NOT EXISTS `employees` (
  `employeeNumber` int(11) NOT NULL AUTO_INCREMENT,
  `lastName` varchar(50) NOT NULL,
  `firstName` varchar(50) NOT NULL,
  `extension` varchar(10) NOT NULL,
  `email` varchar(100) NOT NULL,
  `officeCode` varchar(10) NOT NULL,
  `file_url` varchar(250) CHARACTER SET utf8 NOT NULL,
  `jobTitle` varchar(50) NOT NULL,
  PRIMARY KEY (`employeeNumber`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1703 ;
 
 
INSERT INTO `employees` (`employeeNumber`, `lastName`, `firstName`, `extension`, `email`, `officeCode`, `file_url`, `jobTitle`) VALUES
(1002, 'Murphy', 'Diane', 'x5800', 'dmurphy@classicmodelcars.com', '1', '', 'President'),
(1056, 'Patterson', 'Mary', 'x4611', 'mpatterso@classicmodelcars.com', '1', '', 'VP Sales'),
(1076, 'Firrelli', 'Jeff', 'x9273', 'jfirrelli@classicmodelcars.com', '1', '', 'VP Marketing'),
(1088, 'Patterson', 'William', 'x4871', 'wpatterson@classicmodelcars.com', '6', '', 'Sales Manager (APAC)'),
(1102, 'Bondur', 'Gerard', 'x5408', 'gbondur@classicmodelcars.com', '4', 'pdftest.pdf', 'Sale Manager (EMEA)'),
(1143, 'Bow', 'Anthony', 'x5428', 'abow@classicmodelcars.com', '1', '', 'Sales Manager (NA)'),
(1165, 'Jennings', 'Leslie', 'x3291', 'ljennings@classicmodelcars.com', '1', '', 'Sales Rep'),
(1166, 'Thompson', 'Leslie', 'x4065', 'lthompson@classicmodelcars.com', '1', '', 'Sales Rep'),
(1188, 'Firrelli', 'Julie', 'x2173', 'jfirrelli@classicmodelcars.com', '2', 'test-2.pdf', 'Sales Rep'),
(1216, 'Patterson', 'Steve', 'x4334', 'spatterson@classicmodelcars.com', '2', '', 'Sales Rep'),
(1286, 'Tseng', 'Foon Yue', 'x2248', 'ftseng@classicmodelcars.com', '3', '', 'Sales Rep'),
(1323, 'Vanauf', 'George', 'x4102', 'gvanauf@classicmodelcars.com', '3', '', 'Sales Rep'),
(1337, 'Bondur', 'Loui', 'x6493', 'lbondur@classicmodelcars.com', '4', '', 'Sales Rep'),
(1370, 'Hernandez', 'Gerard', 'x2028', 'ghernande@classicmodelcars.com', '4', '', 'Sales Rep'),
(1401, 'Castillo', 'Pamela', 'x2759', 'pcastillo@classicmodelcars.com', '4', '', 'Sales Rep'),
(1501, 'Bott', 'Larry', 'x2311', 'lbott@classicmodelcars.com', '7', '', 'Sales Rep'),
(1504, 'Jones', 'Barry', 'x102', 'bjones@classicmodelcars.com', '7', '', 'Sales Rep'),
(1611, 'Fixter', 'Andy', 'x101', 'afixter@classicmodelcars.com', '6', '', 'Sales Rep'),
(1612, 'Marsh', 'Peter', 'x102', 'pmarsh@classicmodelcars.com', '6', '', 'Sales Rep'),
(1619, 'King', 'Tom', 'x103', 'tking@classicmodelcars.com', '6', '', 'Sales Rep'),
(1621, 'Nishi', 'Mami', 'x101', 'mnishi@classicmodelcars.com', '5', '', 'Sales Rep'),
(1625, 'Kato', 'Yoshimi', 'x102', 'ykato@classicmodelcars.com', '5', '', 'Sales Rep'),
(1702, 'Gerard', 'Martin', 'x2312', 'mgerard@classicmodelcars.com', '4', '', 'Sales Rep');

Jalankan menggunakan phpmyadmin


Pastikan sisinya seperti Digambar



edit ke controller dengan nama Core.php/

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Core extends CI_Controller {
 
    function __construct()
    {
        parent::__construct();
 
        /* Standard Libraries of codeigniter are required */
        $this->load->database();
        $this->load->helper('url');
        /* ------------------ */ 
 
        $this->load->library('grocery_CRUD');
 
    }
 
    public function index()
    {
        echo "<h1>Welcome to the world of Codeigniter</h1>";//Just an example to ensure that we get into the function
        die();
    }
 
    public function employees()
    {
        $crud = new grocery_CRUD();
        $crud->set_table('employees');
        $output = $this->grocery_crud->render();
 
        echo "<pre>";
        print_r($output);
        echo "</pre>";
        die();
    }
}
 
/* End of file Core.php */
/* Location: ./application/controllers/Core.php */

Buat View Baru

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
 
<?php 
foreach($css_files as $file): ?>
    <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
 
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
 
    <script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
 
<style type='text/css'>
body
{
    font-family: Arial;
    font-size: 14px;
}
a {
    color: blue;
    text-decoration: none;
    font-size: 14px;
}
a:hover
{
    text-decoration: underline;
}
</style>
</head>
<body>
<!-- Beginning header -->
    <div>
        <a href='<?php echo site_url('examples/offices_management')?>'>Offices</a> | 
        <a href='<?php echo site_url('examples/employees_management')?>'>Employees</a> |
        <a href='<?php echo site_url('examples/customers_management')?>'>Customers</a> |
        <a href='<?php echo site_url('examples/orders_management')?>'>Orders</a> |
        <a href='<?php echo site_url('examples/products_management')?>'>Products</a> | 
        <a href='<?php echo site_url('examples/film_management')?>'>Films</a>
    </div>
<!-- End of header-->
    <div style='height:20px;'></div>  
    <div>
        <?php echo $output; ?>
 
    </div>
<!-- Beginning footer -->
<div>Footer</div>
<!-- End of Footer -->
</body></html> 

Simpan dengan nama v_core.php

update kembali file Core.php dengan script

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Core extends CI_Controller {
 
    function __construct()
    {
        parent::__construct();
 
        /* Standard Libraries of codeigniter are required */
        $this->load->database();
        $this->load->helper('url');
        /* ------------------ */ 
 
        $this->load->library('grocery_CRUD');
 
    }
 
    public function index()
    {
        echo "<h1>Welcome to the world of Codeigniter</h1>";//Just an example to ensure that we get into the function
                die();
    }
 
    public function employees()
    {
        $crud = new grocery_CRUD();
        $crud->set_table('employees');
        $output = $crud->render();
 
        $this->_example_output($output);        
    }
 
    function _example_output($output = null)
 
    {
        $this->load->view('v_core.php',$output);    
    }
}
 
/* End of file Core.php */ 

Jalankan kembali file url dan tampilannya seperti gambar tersebut