-See also the list of [colaboradores](http://github.com/giovanniramos/PDO4YOU/contributors) who participated in this project.
+See also the list of [colaboradores](http://github.com/giovanniramos/PDO4You/contributors) who participated in this project.
License
--------------------------------------------------
-Copyright (c) 2013 [Giovanni Ramos](http://github.com/giovanniramos)
+Copyright (c) 2010-2013 [Giovanni Ramos](http://github.com/giovanniramos)
-PDO4You is open-sourced software licensed under the [MIT License](http://www.opensource.org/licenses/MIT) (MIT-LICENSE.txt)
\ No newline at end of file
+PDO4You is open-sourced software licensed under the [MIT License](http://www.opensource.org/licenses/MIT)
\ No newline at end of file
diff --git a/bootstrap.php b/bootstrap.php
index 40cb589..33fbd20 100644
--- a/bootstrap.php
+++ b/bootstrap.php
@@ -1,5 +1,23 @@
AUTOLOADER NOT FOUND';
+ echo 'To continue the installation, click INSTALL and wait, or run install.sh from the command line.
';
+ exit;
+ } else {
+ $output = shell_exec(INSTALL);
+ exit("{$output}
");
+ }
+ }
+}
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 03f41da..8a01f41 100644
--- a/composer.json
+++ b/composer.json
@@ -1,23 +1,27 @@
{
"name": "giovanniramos/pdo4you",
+ "type": "library",
"description": "Access SQL databases using the PDO extension",
"keywords": ["database", "singleton", "pdo", "mysql", "postgresql", "sqlite", "mariadb", "oracle"],
- "homepage": "https://github.com/giovanniramos/PDO4YOU",
- "type": "library",
+ "homepage": "https://github.com/giovanniramos/PDO4You",
"license": "MIT",
"authors": [
{
"name": "Giovanni Ramos",
"email": "giovannilauro@gmail.com",
+ "homepage": "http://twitter.com/giovanni_ramos",
"role": "Developer"
}
],
+ "support": {
+ "issues": "https://github.com/giovanniramos/PDO4You/issues"
+ },
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-0": {
- "PDO4YOU": "src"
+ "PDO4You": "src"
}
}
}
\ No newline at end of file
diff --git a/demos/DemoCRUD.class.php b/demos/DemoCRUD.php
similarity index 86%
rename from demos/DemoCRUD.class.php
rename to demos/DemoCRUD.php
index 4b1dd7b..2b3250c 100644
--- a/demos/DemoCRUD.class.php
+++ b/demos/DemoCRUD.php
@@ -1,26 +1,17 @@
sql();
+ $sql = self::sql();
// Execute the SQL query in a "pre-defined instance" and store the result
$result = PDO4You::select($sql, $instance);
- echo 'Demo with the method PDO4You::select()
';
+ echo 'Demo with the method - PDO4You::select()
';
echo 'PDO4You::select(' . $this->getQuery($sql) . '); ' . $this->getResult($result) . '
';
}
@@ -70,7 +61,7 @@ public function select($instance = null)
public function allSelects()
{
// SQL query
- $sql = $this->sql();
+ $sql = self::sql();
// Execute the SQL query in a instance and store the result
$result_1 = PDO4You::select($sql);
@@ -78,16 +69,16 @@ public function allSelects()
$result_3 = PDO4You::selectObj($sql);
$result_4 = PDO4You::selectAll($sql);
- echo 'Demo with the method PDO4You::select()
';
+ echo 'Demo with the method - PDO4You::select()
';
echo 'PDO4You::select(' . $this->getQuery($sql) . '); ' . $this->getResult($result_1) . '
';
- echo 'Demo with the method PDO4You::selectNum()
';
+ echo 'Demo with the method - PDO4You::selectNum()
';
echo 'PDO4You::selectNum(' . $this->getQuery($sql) . '); ' . $this->getResult($result_2) . '
';
- echo 'Demo with the method PDO4You::selectObj()
';
+ echo 'Demo with the method - PDO4You::selectObj()
';
echo 'PDO4You::selectObj(' . $this->getQuery($sql) . '); ' . $this->getResult($result_3) . '
';
- echo 'Demo with the method PDO4You::selectAll()
';
+ echo 'Demo with the method - PDO4You::selectAll()
';
echo 'PDO4You::selectAll(' . $this->getQuery($sql) . '); ' . $this->getResult($result_4) . '
';
}
@@ -113,7 +104,7 @@ public function multipleInsert()
// Store the result
$result = PDO4You::execute($json);
- echo 'Demo with the method PDO4You::execute() using the INSERT command
';
+ echo 'Demo with the method - PDO4You::execute() using the INSERT command
';
echo 'PDO4You::execute(' . $this->getQuery($json) . '); ' . $this->getResult($result, true) . '
';
}
@@ -149,7 +140,7 @@ public function multipleUpdate()
// Store the result
$result = PDO4You::execute($json);
- echo 'Demo with the method PDO4You::execute() using the UPDATE command
';
+ echo 'Demo with the method - PDO4You::execute() using the UPDATE command
';
echo 'PDO4You::execute(' . $this->getQuery($json) . '); ' . $this->getResult($result) . '
';
}
@@ -181,7 +172,7 @@ public function multipleDelete()
// Store the result
$result = PDO4You::execute($json);
- echo 'Demo with the method PDO4You::execute() using the DELETE command
';
+ echo 'Demo with the method - PDO4You::execute() using the DELETE command
';
echo 'PDO4You::execute(' . $this->getQuery($json) . '); ' . $this->getResult($result) . '
';
}
diff --git a/demos/DemoRegister.class.php b/demos/DemoRegister.php
similarity index 80%
rename from demos/DemoRegister.class.php
rename to demos/DemoRegister.php
index 4d98aaa..e8ff5fa 100644
--- a/demos/DemoRegister.class.php
+++ b/demos/DemoRegister.php
@@ -1,10 +1,12 @@
ERROR: ' . $error . '
';
+ self::$message = 'ERROR: ' . $error . '
';
} else {
// SQL insertion in JSON format
$json = '
@@ -54,9 +53,10 @@ public function init()
';
// Performs the new record and store the result
- $result = PDO4You::execute($json);
+ list($total) = PDO4You::execute($json);
- self::$message = 'Register #' . $result[0] . ' added successfully!!
';
+ // Displays a success message
+ self::$message = 'Register #' . $total . ' added successfully!!
';
}
}
@@ -70,7 +70,9 @@ public function init()
* */
public function getMessage()
{
- return self::$message;
+ $message = self::$message;
+
+ return $message;
}
/**
@@ -80,19 +82,20 @@ public function getMessage()
public function getTotalRecords()
{
// Returns the total number of records in paging
- if (PDO4You_pagination::$paging == true) {
- return PDO4You_pagination::getTotalPagingRecords();
+ if (Pagination::getPaging() == true) {
+ return Pagination::getTotalPagingRecords();
} else {
return count(self::$hasRecords);
}
}
/**
- * Displays all records
+ * Displays the records
*
* */
- public function getRecords()
+ public function showRecords()
{
+ // Displays the records if there
if (self::$hasRecords) {
$html = null;
@@ -106,4 +109,4 @@ public function getRecords()
}
}
-}
+}
\ No newline at end of file
diff --git a/demos/demo1.php b/demos/demo1.php
index 27559a7..c66418e 100644
--- a/demos/demo1.php
+++ b/demos/demo1.php
@@ -1,15 +1,12 @@
DEMOS › ALL SELECTS';
+echo '';
// Creating an instance
-$instance = new DemoCRUD;
-
-// Starting the main method
-$instance->init();
+$demo = new DemoCRUD;
// Displaying records between different instances of base
-$instance->allSelects();
\ No newline at end of file
+$demo->allSelects();
\ No newline at end of file
diff --git a/demos/demo2.php b/demos/demo2.php
index 44fb1a6..704775d 100644
--- a/demos/demo2.php
+++ b/demos/demo2.php
@@ -1,21 +1,18 @@
DEMOS › INSERT/UPDATE/DELETE';
// Creating an instance
-$instance = new DemoCRUD;
-
-// Starting the main method
-$instance->init();
+$demo = new DemoCRUD;
// Example with inserting multiple records
-$instance->multipleInsert();
+$demo->multipleInsert();
// Example to update multiple records
-$instance->multipleUpdate();
+$demo->multipleUpdate();
// Example with multiple exclusion of records
-$instance->multipleDelete();
\ No newline at end of file
+$demo->multipleDelete();
\ No newline at end of file
diff --git a/demos/demo3.php b/demos/demo3.php
index 3182036..0690176 100644
--- a/demos/demo3.php
+++ b/demos/demo3.php
@@ -1,31 +1,31 @@
DEMOS › MULTIPLE INSTANCES';
-// Creating an instance
-$instance = new DemoCRUD;
+// Importing classes
+use PDO4You\PDO4You;
-// Starting the main method
-$instance->init();
+// Creating an instance
+$demo = new DemoCRUD;
// Displaying records of the default instance "standard"
-$instance->select();
+$demo->select();
-PDO4You::getInstance('bookstore', 'sqlite:../data/database_bookstore.db');
-PDO4You::getInstance('pdo4you', 'sqlite:../data/database_pdo4you.db');
+PDO4You::getInstance('bookstore', 'sqlite:data/database_bookstore.db');
+PDO4You::getInstance('pdo4you', 'sqlite:data/database_pdo4you.db');
// Displaying records from the data instance: bookstore
-$instance->select('bookstore');
+$demo->select('bookstore');
// Displaying records from the data instance: pdo4you
-$instance->select('pdo4you');
+$demo->select('pdo4you');
// Sets another instance
PDO4You::setInstance('standard');
#PDO4You::setInstance('bookstore');
// Displaying records from the last data instance set
-$instance->select();
\ No newline at end of file
+$demo->select();
\ No newline at end of file
diff --git a/demos/demo4.php b/demos/demo4.php
index 48cb120..00a14e4 100644
--- a/demos/demo4.php
+++ b/demos/demo4.php
@@ -1,32 +1,15 @@
DEMOS › READ RECORDS';
+// Example with text from HTML Editor
+echo 'DEMOS › HTML EDITOR
';
// Creating an instance
-$instance = new DemoRegister;
+$demo = new DemoCRUD;
-// Starting the main method
-$instance->init();
-?>
+// Sample text
+$sample_text = 'Lorem ipsum "dolor" sit amet
';
-
-
-
- getMessage(); ?>
-
-
-
- : getTotalRecords(); ?>
-
- getRecords(); ?>
-
\ No newline at end of file
+// UPDATE books SET description = ? WHERE id = 1
+$demo->updateWhere($sample_text, 1);
\ No newline at end of file
diff --git a/demos/demo5.php b/demos/demo5.php
index d35f77a..8d7cf92 100644
--- a/demos/demo5.php
+++ b/demos/demo5.php
@@ -1,18 +1,27 @@
DEMOS › HTML EDITOR';
+// Example with Read Records
+echo 'DEMOS › READING RECORDS
';
// Creating an instance
-$instance = new DemoCRUD;
+$demo = new DemoRegister;
+?>
-// Starting the main method
-$instance->init();
+
+
-// UPDATE books SET description = ? WHERE id = 1
-$instance->updateWhere($sample_text, 1);
\ No newline at end of file
+ getMessage(); ?>
+
+ : getTotalRecords(); ?>
+
+ showRecords(); ?>
+
\ No newline at end of file
diff --git a/demos/demo6.php b/demos/demo6.php
index 58f3f37..3898105 100644
--- a/demos/demo6.php
+++ b/demos/demo6.php
@@ -1,43 +1,41 @@
DEMOS › PAGINATION';
+echo 'DEMOS › READING WITH PAGING
';
+
+// Importing classes
+use PDO4You\Pagination as pager;
// Enable pagination
-PDO4You::setPagination();
+pager::setPagination();
// Sets the page link
-PDO4You::setLink('?p=demo6.php&n=');
+pager::setPageLink('?p=demos/demo6.php&n=');
// Sets the current page navigation
-PDO4You::setPage(isset($_GET['n']) ? (int) $_GET['n'] : 1);
+pager::setPage(isset($_GET['n']) ? (int) $_GET['n'] : 1);
// Creating an instance
-$instance = new DemoRegister;
-
-// Starting the main method
-$instance->init();
+$demo = new DemoRegister;
?>
- getMessage(); ?>
-
-
+ getMessage(); ?>
- : getTotalRecords(); ?>
+ : getTotalRecords(); ?>
- getRecords(); ?>
+ showRecords(); ?>
-
+
\ No newline at end of file
diff --git a/demos/index.php b/index.php
similarity index 58%
rename from demos/index.php
rename to index.php
index 739aa2c..8fd8b03 100644
--- a/demos/index.php
+++ b/index.php
@@ -1,18 +1,16 @@
@@ -20,7 +18,9 @@
PDO4You