public static function run($obj, $webClass)
 {
     if ($obj instanceof Model) {
         $cmd = isset($_GET['cmd']) ? addslashes($_GET['cmd']) : 'read';
         if ($cmd == "edit") {
             Crud::createForm($obj, $webClass);
             die;
         }
         if ($cmd == "add") {
             //Crud::createForm($obj,$webClass);
             $json = Crud::addPrecon($obj);
             die(json_encode($json));
         }
         if ($cmd == "delete") {
             $json['bool'] = 1;
             $id = isset($_POST['id']) ? addslashes($_POST['id']) : '';
             $json['bool'] = $obj->delete($id);
             die(json_encode($json));
         }
         if ($cmd == "ws") {
             Crud::workWebService($obj, $webClass);
             die;
         }
         Crud::read($obj, $webClass);
     } else {
         die('Crud hanya bisa dipakai dengan object Crud');
     }
 }
Ejemplo n.º 2
0
<?php

error_reporting(E_ALL);
ob_start("ob_gzhandler");
require_once 'CrudClass.php';
$read = new Crud();
$read->read();
echo '<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Squro tree</title>
    <link rel="stylesheet" href="squro.css">
    <script type="text/javascript" src="squro.js"></script>
</head>
<body>
<h1>Squro tree</h1><ul class="node">' . $read->show . '</ul></body>
</html>';
Ejemplo n.º 3
0
            echo "error:" . $sql . "<br>" . $conn->error;
        }
    }
    public function update()
    {
        $sql = " Update faqs SET answer ='woh'  WHERE id=1";
        if ($this->conn->query($sql) === TRUE) {
            echo "Record updated successfully";
        } else {
            echo "Error updating record: " . $conn->error;
        }
    }
    public function __destruct()
    {
        $this->conn->close();
    }
}
$crud = new Crud();
switch ($_GET['action']) {
    case "read":
        $crud->read();
        break;
    case "update":
        $crud->update();
        break;
    case "delete":
        break;
    case "insert":
        $crud->insert();
        break;
}
Ejemplo n.º 4
0
<?php 
include_once 'model.php';
$readInstantiate = new Crud();
$getData = $readInstantiate->read();
//var_dump($getData);
if (isset($_REQUEST['del_id'])) {
    $readInstantiate->delete($_REQUEST['del_id']);
    header("location : read.php");
}
?>
<table>
	<tr>
		<td>S.No.</td>
		<td>Name</td>
		<td>Address</td>
		<td>Phone</td>
		<td>Gender</td>
	</tr>
	<?php 
$i = 1;
?>
	<?php 
foreach ($getData as $key => $value) {
    ?>
	<tr>
		<td><?php 
    echo $i++;
    ?>
</td>
		<td><?php