some MDB2 questions
| From: | Andreas Korthaus | Date: | Thu, 10 Feb 2005 11:02:43 +0000 |
| Subject: | some MDB2 questions | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-36114@lists.php.net to get a copy of this message | ||
Hi!
After some time I found out that affectedRows() has been removed in CVS-Version after beta2 release of MDB2. But why (many people use it in PEAR::DB, ADOdb...)? So I have to use the return-value of query(), correct?
But how can I use something like numRows() as in DB_Result? Should I request the $rownum property?
I'm not sure if the two methodes from PEAR::DB Wrapper (peardb.php) can work correct in CVS-Version:
function affectedRows()
{
return $this->db_object->affectedRows();} function numRows($result) {
$result = $this->_wrapResource($result);
return $result->numRows();
}
Is
ini_set('include_path', '../..'.PATH_SEPARATOR.ini_get('include_path'));
really necessary?
Does MDB2 support a syntax similar to ADOdb's
while (!$rs->EOF) {
print_r($rs->fields);
$rs->MoveNext();
}
?
What is necessary to use the iterator from Iterator.php (foreach...)?
I tried to write an autoExecute() methode for ADOdb (http://phplens.com/lens/lensforum/msgs.php?id=11643). Now it is implemented there, but not my version, which I wrote on base of PEAR::DB/MDB/2, perhaps it is useful for you, I reduced the changes to buildManipSQL() from Extended.php:
function buildManipSQL($table, $table_fields, $mode, $where = false)
{
$db =& $GLOBALS['_MDB2_databases'][$this->db_index];
if (count($table_fields) == 0) {
$db->raiseError(MDB2_ERROR_NEED_MORE_DATA);
}
switch ($mode) {
case MDB_AUTOQUERY_INSERT:
$cols = implode(',', array_keys($table_fields));
$values = '?'.str_repeat(',?', count($table_fields)-1);
return 'INSERT INTO '.$table.' ('.$cols.') VALUES ('.$values.')';
break;
case MDB_AUTOQUERY_UPDATE:
$set = implode('= ?,', array_keys($table_fields)).'= ?';
$sql = 'UPDATE '.$table.' SET '.$set;
if ($where !== false) $sql .= ' WHERE '.$where;
return $sql;
break;
default:
$db->raiseError(MDB2_ERROR_SYNTAX);
}
}
Will there be a beta3 release in near future?
best regards
Andreas