+ Add getColumns function for dao.
This commit is contained in:
@@ -700,6 +700,36 @@ class baseDAO
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回SQL结果的所有字段信息。
|
||||
* Return the fields meta of PDOStatement.
|
||||
*
|
||||
* @param string|PDOStatement $stmt
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getColumns($stmt)
|
||||
{
|
||||
/* 如果是SQL查询语句,先执行查询获得 PDO stmt. */
|
||||
/* If it is SQL string, query to get PDO stmt. */
|
||||
if(is_string($stmt)) $stmt = $this->query($stmt);
|
||||
|
||||
$fields = array();
|
||||
try
|
||||
{
|
||||
for($columnIndex = 0; $columnIndex < $stmt->columnCount(); $columnIndex++)
|
||||
{
|
||||
$fields[] = $stmt->getColumnMeta($columnIndex);
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->sqlError($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将记录进行分页,自动设置limit语句。
|
||||
* Page the records, set the limit part auto.
|
||||
|
||||
Reference in New Issue
Block a user