function canonicalizeType($type) { $typeinfo = new lmbDbTypeInfo(); $typelist = $typeinfo->getColumnTypeList(); if (!in_array($type, $typelist)) { throw new lmbDbException("Invalid column type '{$type}'"); } return $type; }
protected function _loadCastMethods($record) { if (sizeof($this->cast_methods)) { return; } static $accessors; if (!isset($accessors)) { $typeinfo = new lmbDbTypeInfo(); $accessors = $typeinfo->getColumnTypeGetters(); } foreach ($this->db_column_names as $name) { if ($info = $this->db_table->getColumnInfo($name)) { $this->cast_methods[$name] = $accessors[$info->getType()]; } else { $this->cast_methods[$name] = ''; } } }
function testGetColumnTypeAccessors() { $mapping = lmbDbTypeInfo::getColumnTypeAccessors(); foreach ($this->columnList as $columnType) { $this->assertTrue(isset($mapping[$columnType])); } foreach ($mapping as $col => $name) { $this->assertTrue(in_array($col, $this->columnList)); $this->assertTrue(is_callable(array($this->queryStmtClass, $name)), "'{$name}' is not callable in {$this->queryStmtClass}"); } }
function setTypedValue($type, $column, $value) { $setterList = lmbDbTypeInfo::getColumnTypeAccessors(); $setter = $setterList[$type]; $this->assertNotNull($setter); $sql = "\n INSERT INTO standard_types (\n {$column}\n ) VALUES (\n :{$column}:\n )"; $stmt = $this->connection->newStatement($sql); $stmt->{$setter}($column, $value); $id = $stmt->insertId('id'); $sql = "SELECT * FROM standard_types WHERE id = :id:"; $stmt = $this->connection->newStatement($sql); $stmt->setInteger('id', $id); $record = $stmt->getOneRecord(); return $record; }
protected function _bindValuesToStatement($stmt, $values) { $accessors = lmbDbTypeInfo::getColumnTypeAccessors(); foreach ($values as $key => $value) { $accessor = $accessors[$this->getColumnInfo($key)->getType()]; $stmt->{$accessor}($key, $value); } }