Browse Source

Merge pull request #1743 from greg-hellings/clean_zend1

Clean up warnings for zend1
blee-techempower 9 years ago
parent
commit
80e27af336

+ 1 - 0
frameworks/PHP/zend1/application/configs/application.ini

@@ -4,6 +4,7 @@ phpSettings.display_errors = 1
 bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
 bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
 bootstrap.class = "Bootstrap"
 bootstrap.class = "Bootstrap"
 resources.frontcontroller.controllerDirectory = APPLICATION_PATH "/controllers"
 resources.frontcontroller.controllerDirectory = APPLICATION_PATH "/controllers"
+resources.frontcontroller.moduledirectory = APPLICATION_PATH
 resources.frontcontroller.params.displayExceptions = 1
 resources.frontcontroller.params.displayExceptions = 1
 
 
 resources.db.adapter = "pdo_mysql"
 resources.db.adapter = "pdo_mysql"

+ 1 - 1
frameworks/PHP/zend1/application/controllers/DbController.php

@@ -4,7 +4,7 @@ class DbController extends Zend_Controller_Action
 {
 {
     public function indexAction()
     public function indexAction()
     {
     {
-        $table = new Zend_Db_Table('World');
+        $table = new Model_World();
         $result = $table->fetchRow(array('id = ?' => mt_rand(1, 10000)));
         $result = $table->fetchRow(array('id = ?' => mt_rand(1, 10000)));
 
 
         $this->_helper->json->sendJson($result->toArray());
         $this->_helper->json->sendJson($result->toArray());

+ 1 - 1
frameworks/PHP/zend1/application/controllers/DbMultiController.php

@@ -8,7 +8,7 @@ class DbMultiController extends Zend_Controller_Action
         $queries = max(1, $queries);
         $queries = max(1, $queries);
         $queries = min(500, $queries);
         $queries = min(500, $queries);
 
 
-        $table = new Zend_Db_Table('World');
+        $table = new Model_World();
 
 
         $worlds = array();
         $worlds = array();
         for ($i = 0; $i < $queries; $i += 1) {
         for ($i = 0; $i < $queries; $i += 1) {

+ 10 - 0
frameworks/PHP/zend1/application/models/World.php

@@ -0,0 +1,10 @@
+<?php
+class Model_World extends Zend_Db_Table_Abstract {
+	protected $_name = 'World';
+
+	public function __construct() {
+		parent::__construct(array(
+			'rowClass' => 'Model_WorldRow'
+		));
+	}
+}

+ 10 - 0
frameworks/PHP/zend1/application/models/WorldRow.php

@@ -0,0 +1,10 @@
+<?php
+class Model_WorldRow extends Zend_Db_Table_Row_Abstract {
+	public function __construct($config = array()) {
+		if ( array_key_exists('data', $config) ) {
+			$config['data']['id'] = (int) $config['data']['id'];
+			$config['data']['randomNumber'] = (int) $config['data']['randomNumber'];
+		}
+		parent::__construct($config);
+	}
+}

+ 7 - 0
frameworks/PHP/zend1/public/index.php

@@ -10,6 +10,13 @@ defined('APPLICATION_ENV')
 
 
 set_include_path(realpath(dirname(__FILE__) . '/../vendor/zendframework/zendframework1/library'));
 set_include_path(realpath(dirname(__FILE__) . '/../vendor/zendframework/zendframework1/library'));
 
 
+require_once 'Zend/Loader/Autoloader/Resource.php';
+$resources = new Zend_Loader_Autoloader_Resource(array(
+	'namespace' => '',
+	'basePath' => APPLICATION_PATH
+));
+$resources->addResourceType('model', 'models', 'Model');
+
 require_once 'Zend/Application.php';
 require_once 'Zend/Application.php';
 
 
 // Create application, bootstrap, and run
 // Create application, bootstrap, and run