Permalink
Browse files

identifier placeholder ?# with table name specifier

git-svn-id: svn://dklab.ru/lib/DbSimple/trunk@206 78bb956b-1e24-0410-b8d0-c528fdc9eae3
  • Loading branch information...
1 parent 05465c1 commit e3a9060f3d2fa1485739c19c12536fe7e6c07863 dk committed Jul 2, 2007
Showing with 18 additions and 2 deletions.
  1. +2 −2 lib/DbSimple/Generic.php
  2. +16 −0 t/DbSimple/Generic/080_table_ident_pholder.phpt
View
@@ -821,9 +821,9 @@ function _expandPlaceholdersCallback($m)
// Identifier.
if (!is_array($value)) return $this->escape($value, true);
$parts = array();
- foreach ($value as $identifier) {
+ foreach ($value as $table => $identifier) {
if (!is_string($identifier)) return 'DBSIMPLE_ERROR_ARRAY_VALUE_NOT_STRING';
- $parts[] = $this->escape($identifier, true);
+ $parts[] = (!is_int($table)? $this->escape($table, true) . '.' : '') . $this->escape($identifier, true);
}
return join(', ', $parts);
case 'n':
@@ -0,0 +1,16 @@
+--TEST--
+Generic: identifier placeholderwith tablename
+--FILE--
+<?php
+require_once dirname(__FILE__) . '/../init.php';
+
+function main(&$DB)
+{
+ @$DB->query("SELECT ?# FROM t1", array('a', 'b'));
+ @$DB->query("SELECT ?# FROM t1", array('t1' => 'a', 'b'));
+}
+
+?>
+--EXPECT--
+Query: 'SELECT `a`, `b` FROM t1'
+Query: 'SELECT `t1`.`a`, `b` FROM t1'

0 comments on commit e3a9060

Please sign in to comment.