Browse Source

Zend framework 1 setup dev/test db script

Gerard Roche 11 years ago
parent
commit
52d62c80dc
1 changed files with 26 additions and 0 deletions
  1. 26 0
      frameworks/PHP/php-zend-framework1/script/setup_dev_and_test_db.php

+ 26 - 0
frameworks/PHP/php-zend-framework1/script/setup_dev_and_test_db.php

@@ -0,0 +1,26 @@
+<?php
+
+set_include_path(realpath(dirname(__FILE__) . '/../vendor/zendframework/zendframework1/library'));
+
+require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
+$db = new Zend_Db_Adapter_Pdo_Mysql(array(
+    'host' => 'localhost',
+    'charset' => 'utf8',
+    'dbname'   => 'hello_world',
+    'username' => 'benchmarkdbuser',
+    'password' => 'benchmarkdbpass'
+));
+
+$db->exec('DROP TABLE IF EXISTS `World`;');
+$db->exec('CREATE TABLE `World` (
+  `id` int(11) NOT NULL,
+  `randomNumber` int(11) NOT NULL,
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
+
+for ($i=1; $i <= 10000; $i++) {
+    $db->insert('World', array(
+        'id' => $i,
+        'randomNumber' => $i
+    ));
+}