projects
/
m6w6
/
pq-gateway
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
add support for one-dimensional arrays; type input parameters
[m6w6/pq-gateway]
/
lib
/
pq
/
Gateway
/
Table.php
diff --git
a/lib/pq/Gateway/Table.php
b/lib/pq/Gateway/Table.php
index a25b2ad3fd6e07008bf59f27caa56239293756ac..e4adbb7a532642e23005871f27c6e16ea100f436 100644
(file)
--- a/
lib/pq/Gateway/Table.php
+++ b/
lib/pq/Gateway/Table.php
@@
-53,6
+53,11
@@
class Table
*/
protected $identity;
*/
protected $identity;
+ /**
+ * @var \pq\Gateway\Table\Attributes
+ */
+ protected $attributes;
+
/**
* @var \pq\Gateway\Table\Relations
*/
/**
* @var \pq\Gateway\Table\Relations
*/
@@
-205,6
+210,13
@@
class Table
return $this->identity;
}
return $this->identity;
}
+ function getAttributes() {
+ if (!isset($this->attributes)) {
+ $this->attributes = new Table\Attributes($this);
+ }
+ return $this->attributes;
+ }
+
/**
* Get foreign key relations
* @param string $to fkey
/**
* Get foreign key relations
* @param string $to fkey
@@
-430,7
+442,7
@@
class Table
$params = array();
foreach ($data as $key => $val) {
$query->write($first ? "(" : ",", $key);
$params = array();
foreach ($data as $key => $val) {
$query->write($first ? "(" : ",", $key);
- $params[] = $query->param($val);
+ $params[] = $query->param($val
, $this->getAttributes()->getColumn($key)->type
);
$first and $first = false;
}
$query->write(") VALUES (", $params, ")");
$first and $first = false;
}
$query->write(") VALUES (", $params, ")");
@@
-456,7
+468,8
@@
class Table
$query->write("UPDATE", $this->conn->quoteName($this->name));
$first = true;
foreach ($data as $key => $val) {
$query->write("UPDATE", $this->conn->quoteName($this->name));
$first = true;
foreach ($data as $key => $val) {
- $query->write($first ? "SET" : ",", $key, "=", $query->param($val));
+ $query->write($first ? "SET" : ",", $key, "=",
+ $query->param($val, $this->getAttributes()->getColumn($key)->type));
$first and $first = false;
}
$query->write("WHERE")->criteria($where);
$first and $first = false;
}
$query->write("WHERE")->criteria($where);