Database CRUD
Want a successful Modern site?
Start with IQRA training; it’s easy and quick to your needs.
Do Database Crud Operations with IQRA CMS Easy and Fast
-
insertdata()Parametors
- data (array data) (required)
- table name (string) (required)
$data = [ key => val]; $data += [ key=> val]; insertdata($data, $tablename)-
updatedata()Parametors
- data (array data) (required)
- condition (string) (required)
- table name (string) (required)
$data = [ key => val]; $data += [ key=> val]; $condition = 'id="2"'; updatedata($data, $condition $tablename)-
deletedata()Parametors
- table name (string) (required)
- condition (string) (required)
deletedata($tablename, 'id="12"')-
tablexist()Parametors
- table name (string) (required)
- condition (string) (optional)
condition
- get (For Get All table table names)
- Leave Blank (For return blank)
// check tables tablexist($tablename) // get tables names tablexist($tablename, $datacondition = null)
-
fetch()Parametors
- table name (string) (required)
- condition (string) (required)
fetch($tablename, $condition) // output array('key'=>'value')
Class ($db)
- fetch_all()
Parametors
- table name (string) (required)
- condition (string) (optional)
- pagination (bolean (true / false)) (optional)
-
limit (Fetch Limit (int)) (Optional)
- search (bolean (true / false)) (optional)
Global $db; $data = $db->fetch_all($tablename, $condition=null, $pagination = null, $limit=null, $search=null);
How to use Pagination
// How to use pagination $data = $db->fetch_all($tablename, $condition=null, true, 10, true); echo ' <ul class="pagination">'; $paginationdata = $db->paginationlast(); foreach($paginationdata as $paginationcount){ foreach($paginationcount as $data=>$val){ if(isset($_GET['page'])){$page = $_GET['page'];}else{ $page = 1;} if($data == $page){$pagistatus = 'active';}else{$pagistatus = '';} echo '<li class="page-item '.$pagistatus.'"><a class="page-link" href="'. $val .'">'.$data.'</a></li>'; }} echo ' </ul></nav>'; $totalcount = $db->paginationlast('total'); echo ' <div class="fw-normal small mt-4 mt-lg-0">Showing <b>'. $totalcount[0].'</b> out of <b>'. $totalcount[1].'</b> entries</div>'; echo '</ul>';How to use Search
$data = $db->fetch_all($tablename, $condition=null, $pagination = null, $limit=null, true); // Use Get Request with search parameter www.example.com?search=hello1. Fetch Data without Duplicate Entry.
-
fetch_distictdata()Parametors
- table name (string) (required)
- data (string) (required)
fetch_distictdata($tablename, 'user)