PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2 » Bug #6498

execute() fails to construct the sql command (with solution)

Details

Submitted2006-01-15 23:17 UTC
Fromkuu at ivmasters dot ru
Assignedlsmith
StatusClosed
PackageMDB2
PHP Version5.1.1
OSwin32
Roadmaps(Not assigned)

Comments

[2006-01-15 23:17 UTC] kuu at ivmasters dot ru

Description:
------------
I have lastest MDB2.php from cvs.

Test script:
---------------
Example:

$stmt = $mdb2->prepare( 'select * from :table where name=:name", array('text', 'text' );

// Constructs wrong sql-statement because parameter order in
// value array differs from parameter order in query
$stmt->execute( array('name'=>'victor', 'table'=>'users' ) );

Expected result:
----------------
I have done one changes in mdb2.php in prepare():

$position = $p_position;
}
}

// Excuse me, I forgot what does it mean and my english is very bad, but these sorting solves the problem above. Main idea is to make value order equal to parameter order in query.
asort($positions);

$class_name = 'MDB2_Statement_'.$this->phptype;
$obj =& new $class_name($this, $positions, $query, $types, $result_types, $is_manip, $this->row_limit, $this->row_offset);