Hi,
Susan had pointed to some DB enhancements and a few other things. I’ve managed to pull together a few APIs based on some of the ideas put forward in the forums
What do you think about these API functions?
$modx->db // DBAPI object
$modx->db->config[] // config array
$modx->db->select($fields,$table,$where,$orderby,$limit)
$modx->db->update($fields,$table,$where)
$modx->db->delete($table,$where)
$modx->db->insert($fields,$table)
$modx->db->getValue($ds)
$modx->db->getRow($ds)
$modx->db->getColumn($name,$ds);
$modx->db->getXML($ds)
$modx->db->getHTMLGrid($ds,$params)
$modx->db->getRecordCount($ds)
$modx->db->setConnection($host,$uid,$pwd)
$modx->db->query($sql) // we should really use select, update, insert, etc
-
MODX Staff
- 12,272 Posts
How do these DB functions differ from the other external DB functions? Are the APIs a clone of EZsql?
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
Quote from: rthrash at Jun 13, 2005, 04:01 PM
How do these DB functions differ from the other external DB functions? Are the APIs a clone of EZsql?
It’s kindof a mix of EzSQL and Rad’s DB API functions but it’s built just for MODx. For example, the getHTMLGrid() function will process an entire recordset and return the result as a datagrid. The getXML() function will convert an enitre recordset into an XML string
-
☆ A M B ☆
- 24,524 Posts
A mysql_insert_id() function would come in handy. Or maybe the modx->insert() function would return the ID?
Quote from: sottwell at Jun 14, 2005, 12:03 AM
A mysql_insert_id() function would come in handy.? Or maybe the modx->insert() function would return the ID?
That’s true. Maybe something like getInsertId() or maybe we could have the insert() function return the id if the everything went well otherwise it would return a FALSE. Example:
$id = $modx->insert($_POST,"mytable");
if($id===false){
? ?$modx->webAlert("Error while inserting record.");
? ?return;
}