diff --git a/Example1/Example1.php b/Example1/Example1.php index a60cdbb..6a3c4d6 100644 --- a/Example1/Example1.php +++ b/Example1/Example1.php @@ -10,19 +10,7 @@ function __construct() parent::__construct(); - // $this->auth = "WHERE user_id = {$_SESSION['user_id']}"; // we may adjust or fix it later on $this->tbl['cols'] = array( - // 'id' => array( - // 'type' => 'text', - // 'display as' => 'ID', - // 'is display' => array( - // 'on listing' => false, - // 'on view' => false, - // 'on add' => false, - // 'on edit' => false, - // ), - // 'is required' => true, - // ), 'name' => array( 'type' => 'text', 'display as' => 'Name', diff --git a/PRC.php b/PRC.php index 4b48602..ee36771 100644 --- a/PRC.php +++ b/PRC.php @@ -7,7 +7,7 @@ class PRC 'name' => 'PHP RAD CRUD', 'nameShort' => 'PRC', 'desc' => 'PHP - PHP: Hypertext Preprocessor. RAD - Rapid Application Development. CRUD - Create, Read, Update and Delete', - 'version' => '0.1.2', + 'version' => '0.1.3', 'developer' => 'Aamir Shahzad', 'path' => '/opt/lampp/htdocs/PRC', 'pathUrl' => 'http://localhost/PRC', @@ -87,10 +87,7 @@ function __construct($opt = null) function list() { $cols = $this->getCols('on listing'); - $sql = "SELECT {$this->tbl['name']}.id, {$cols['fields']} FROM {$this->tbl['name']};"; - // prd($sql,'$sql'); - $result = mysqli_query( $this->dbConn, $sql @@ -98,7 +95,6 @@ function list() if (mysqli_num_rows($result)) { $row = mysqli_fetch_assoc($result); - // $cols = array_keys($row); } // if num_rows ?>
@@ -290,8 +286,6 @@ function edit($id) $cols = $this->getCols('on edit'); $sql = "SELECT {$this->tbl['name']}.id, {$cols['fields']} FROM {$this->tbl['name']} WHERE id = $id LIMIT 1;"; - // prd($sql,'$sql'); - $result = mysqli_query( $this->dbConn, $sql @@ -358,11 +352,7 @@ function blob($id, $name) $stmt = mysqli_prepare( $this->dbConn, "SELECT {$this->tbl['name']}.$name FROM {$this->tbl['name']} WHERE {$this->tbl['name']}.id = ? LIMIT 1;" - // "SELECT {$this->tbl['name']}.$name FROM {$this->tbl['name']} {$this->auth} AND {$this->tbl['name']}.id = ? LIMIT 1;" ); - - // print_r($result); - mysqli_stmt_bind_param($stmt, "i", $id); if (mysqli_stmt_execute($stmt) === true) { @@ -448,7 +438,6 @@ function login() $row = $result->fetch_assoc(); if (!empty($row)) { - // $_SESSION['user_id'] = $row['id']; $_SESSION['user'] = $row; $color = 'green'; header("Location: {$this->app['pathUrl']}/index.php?msg={$msg}&color={$color}"); @@ -495,7 +484,6 @@ function index() function logout() { - // $_SESSION['user_id'] = 0; $_SESSION['user'] = null; $msg = 'You are logged out successfully.'; $color = 'green'; @@ -559,7 +547,5 @@ function showMsg() { if (!empty($_GET['msg'])) { echo "

{$_GET['msg']}

"; - // $_GET['msg'] = ''; - // $_GET['color'] = ''; } // if GET msg } // showMsg() \ No newline at end of file diff --git a/README.md b/README.md index 3f219fd..6aa6141 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,14 @@ PHP RAD CRUD - PHP - PHP: Hypertext Preprocessor - RAD - Rapid Application Development -- CRUD - Create, Read, Update and Delete \ No newline at end of file +- CRUD - Create, Read, Update and Delete + +## How to use? +Update your database details at PRC.php file. + +You can use example.sql database for testing. + +Create new folder for each database table and follow code examples given at +- Example1 folder +- Example2 folder +- Users folder \ No newline at end of file