I'm new to PHP, and was trying to create an Abstract class with a mix of abstract and non-abstract methods, and then extend the class to implement the abstract methods. The following is portions of my two class files:
<?php
require_once 'Zend/Db/Table/Abstract.php';
abstract class ATableModel extends Zend_Db_Table_Abstract {
abstract static function mapValues($post);
abstract static function getTableName();
public static function newEntry($post) {
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$data = mapValues($post, true);
$db->insert(getTableName(), $data);
$id = $db->lastInsertId();
return $id;
}
public static function getEntry($id){
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$db->setFetchMode(Zend_Db::FETCH_OBJ);
return $db->fetchRow("
SELECT *
FROM ".getTableName()."
WHERE ID = '".(int)$id."'
"
);
}
public static function editEntry($id,$post) {
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$data = mapValues($post);
$db->update(getTableName(), $data, " ID = '".(int)$id."' ");
}
public static function deleteEntry($id) {
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$db->delete(getTableName()," ID = '".(int)$id."' ");
}
}
?>
The child class looks as follows:
<?php
require_once 'Zend/Db/Table/Abstract.php';
class Testing extends ATableModel {
public static function getTableName()
{
return 'TESTING';
}
public static function mapValues($post)
{
$data = array (
'test_description' => htmlentities($post['testDescription'])
);
return $data;
}
}
?>
Both files are located in the same directory relative to one another. However, when I try to run my application, I get the following error:
Fatal error: Class 'ATableModel' not found in /var/www/testApp/application/models/testing.php on line 20
My guess is that there's something wrong with either the order that I'm loading the files, or with where these files are located, relative to one another. However, I'm not sure how to proceed from here. Suggestions?