/** * */ public function __construct($dbkey = "default") { $obj = PdoPool::getInstance(); $pdo_info = $obj->getPdoInfo($dbkey); $this->db_key = $pdo_info["key"]; $this->pdo = $pdo_info["pdo"]; $this->pdo_config = $pdo_info["config"]; $this->table_name = SInflector::tableize(get_class($this)); $meta_driver = MetaDriverFactory::getInstance(); $this->props = $meta_driver->getColumns($this->pdo, $this->table_name); $this->column_names = array_keys($this->props); $this->vals = array(); foreach ($this->column_names as $name) { $this->vals[$name] = array("value" => null, "is_updated" => false); } foreach ($this->primary_key as $pkey) { if (!in_array($pkey, $this->column_names, true)) { $msg = "No Such property found: " . $pkey; throw new NoSuchPropertyError($msg); } } }
public static function foreign_key($class_name, $separate_class_name_and_id_with_underscore = true) { return SInflector::underscore($class_name) . ($separate_class_name_and_id_with_underscore ? "_id" : "id"); }