From fd1d2b86ffac93a0d6d88581ef9a1e27f469fb04 Mon Sep 17 00:00:00 2001
From: David Grudl Connected to Sqlite';
- echo '';
- echo '
\n";
}
diff --git a/dibi/libs/NObject.php b/dibi/libs/NObject.php
index 0fa5ad6e..0122a82f 100644
--- a/dibi/libs/NObject.php
+++ b/dibi/libs/NObject.php
@@ -76,23 +76,11 @@ abstract class NObject
/**
* Access to reflection
*
- * @return ReflectionClass
+ * @return ReflectionObject
*/
final public function getReflection()
{
- return new ReflectionClass(get_class($this));
- }
-
-
-
- /**
- * Return hash id for given object
- *
- * @return string 32 hexa chars
- */
- final public function getHashId()
- {
- return spl_object_hash($this);
+ return new ReflectionObject($this);
}
@@ -217,7 +205,7 @@ abstract class NObject
/**
- * Is method defined? Case sensitive, filters protected & private, doesn't recognize static methods (works good since 5.0.4)
+ * Does method exist? Case sensitive, filters protected & private, doesn't recognize static methods (works good since 5.0.4)
*
* @param string class name
* @param string method name
@@ -236,4 +224,18 @@ abstract class NObject
+/**
+ * NClass is the ultimate ancestor of all uninstantiable classes.
+ */
+abstract class NClass
+{
+
+ final public function __construct()
+ {
+ throw new LogicException("Cannot instantiate static class " . get_class($this));
+ }
+
}
+
+
+}
\ No newline at end of file
diff --git a/examples/connect.php b/examples/connect.php
index 88eec70b..00d273be 100644
--- a/examples/connect.php
+++ b/examples/connect.php
@@ -1,36 +1,42 @@
-';
- echo ' #row ';
+ echo "\n\n\n\t
';
+ echo "\n\n\t\t ';
- echo '';
- echo '';
+
+ echo "\t\n\n\n";
foreach ($this as $row => $fields) {
- echo '#row \n";
+
foreach ($this->getFields() as $field) {
- echo '' . htmlSpecialChars($field) . ' ';
+ echo "\t\t" . htmlSpecialChars($field) . " \n";
}
- echo '', $row, ' ';
+ echo "\t\n\t\t ';
+ echo "\t\n";
}
- echo '';
- echo '", $row, " \n";
foreach ($fields as $field) {
//if (is_object($field)) $field = $field->__toString();
- echo '', htmlSpecialChars($field), ' ';
+ echo "\t\t", htmlSpecialChars($field), " \n";
}
- echo 'dibi connect example
+dibi::connect() example
Connecting to Sqlite: ';
try {
dibi::connect(array(
'driver' => 'sqlite',
'database' => 'sample.sdb',
));
- echo '', $e, '
';
+ echo get_class($e), ': ', $e->getMessage();
}
+echo "
Connecting to MySQL: '; try { dibi::connect('driver=mysql&host=localhost&username=root&password=xxx&database=test&charset=utf8'); - echo '
Connected to MySQL
'; + echo 'OK'; } catch (DibiException $e) { - echo '', $e, ''; + echo get_class($e), ': ', $e->getMessage(); } +echo "\n"; // connects to MySQLi using array +echo '
Connecting to MySQL: '; try { dibi::connect(array( 'driver' => 'mysqli', @@ -40,16 +46,18 @@ try { 'database' => 'dibi', 'charset' => 'utf8', )); - echo '
Connected to MySQL
'; + echo 'OK'; } catch (DibiException $e) { - echo '', $e, ''; + echo get_class($e), ': ', $e->getMessage(); } +echo "\n"; // connects to ODBC +echo '
Connecting to ODBC: '; try { dibi::connect(array( 'driver' => 'odbc', @@ -57,46 +65,52 @@ try { 'password' => '***', 'database' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq='.dirname(__FILE__).'/sample.mdb', )); - echo '
Connected to ODBC
'; + echo 'OK'; } catch (DibiException $e) { - echo '', $e, ''; + echo get_class($e), ': ', $e->getMessage(); } +echo "\n"; // connects to PostgreSql +echo '
Connecting to PostgreSql: '; try { dibi::connect(array( 'driver' => 'postgre', 'string' => 'host=localhost port=5432 dbname=mary', 'persistent' => TRUE, )); - echo '
Connected to PostgreSql
'; + echo 'OK'; } catch (DibiException $e) { - echo '', $e, ''; + echo get_class($e), ': ', $e->getMessage(); } +echo "\n"; // connects to PDO +echo '
Connecting to Sqlite via PDO: '; try { dibi::connect(array( 'driver' => 'pdo', 'dsn' => 'sqlite2::memory:', )); - echo '
Connected to Sqlite via PDO
'; + echo 'OK'; } catch (DibiException $e) { - echo '', $e, ''; + echo get_class($e), ': ', $e->getMessage(); } +echo "\n"; // connects to MS SQL +echo '
Connecting to MS SQL: '; try { dibi::connect(array( 'driver' => 'mssql', @@ -104,15 +118,17 @@ try { 'username' => 'root', 'password' => 'xxx', )); - echo '
Connected to MS SQL
'; + echo 'OK'; } catch (DibiException $e) { - echo '', $e, ''; + echo get_class($e), ': ', $e->getMessage(); } +echo "\n"; // connects to Oracle +echo '
Connecting to Oracle: '; try { dibi::connect(array( 'driver' => 'oracle', @@ -120,8 +136,9 @@ try { 'password' => 'xxx', 'database' => 'db', )); - echo '
Connected to Oracle
'; + echo 'OK'; } catch (DibiException $e) { - echo '', $e, ''; + echo get_class($e), ': ', $e->getMessage(); } +echo "\n"; \ No newline at end of file diff --git a/examples/date.type.demo.php b/examples/date.type.demo.php index 2a54f8ee..a8afd2e8 100644 --- a/examples/date.type.demo.php +++ b/examples/date.type.demo.php @@ -1,4 +1,4 @@ -
', $e, ''; + echo '
', get_class($e), ': ', $e->getMessage(), '
'; }