FLEAPHP提供了自动化的crud操作,可以直接调用其save等接口。
但是,不可避免的需要一些复杂的sql语句,这时就可以使用 TableDataGateway.php 提供的findBySql接口。
比如:
function actionCyTest(){
ini_set("display_errors", "On");
error_reporting(E_ALL);
FLEA::loadClass("Table_FishingContent");
FLEA::loadClass("Helper_GetDomain");
$this->tbReport =& FLEA::getSingleton("Table_FishingContent");
var_dump($this->tbReport->findBySql('select * from fishing_content limit 1'));
exit;
}
在默认control里增加了一个这样的函数,通过/index.php?controller=Default&action=cytest访问,即可获取该sql句子的结果。
附FLEA/Db/TableDataGateway.php 的方法:
function FLEA_Db_TableDataGateway($params = null)
function setDBO(& $dbo)
function & getDBO()
function & find($conditions, $sort = null, $fields = '*', $queryLinks = true)
function & findAll($conditions = null, $sort = null, $limit = null, $fields = '*', $queryLinks = true)
$callback = create_function('& $r, $o, $m', '$r[$m] = null;');
function assembleRecursionRow($mappingName, & $row, $enabledLinks = null)
function assembleRecursionRowset($mappingName, & $rowset, $enabledLinks = null)
function & findByField($field, $value, $sort = null, $fields = '*')
function & findAllByField($field, $value, $sort = null, $limit = null, $fields = '*')
function & findAllByPkvs($pkvs, $conditions = null, $sort = null, $limit = null, $fields = '*', $queryLinks = true)
function & findBySql($sql, $limit = null)
function findCount($conditions = null, $fields = null)
function save(& $row, $saveLinks = true, $updateCounter = true)
function saveRowset(& $rowset, $saveLinks = true)
function replace(& $row) {
function replaceRowset(& $rowset)
function update(& $row, $saveLinks = true)
function updateRowset(& $rowset, $saveLinks = true)
function updateByConditions($conditions, & $row)
function updateField($conditions, $field, $value)
function incrField($conditions, $field, $incr = 1)
function decrField($conditions, $field, $decr = 1)
function create(& $row, $saveLinks = true)
function createRowset(& $rowset, $saveLinks = true)
function remove(& $row, $removeLink = true)
function removeByPkv($pkv, $removeLink = true)
function removeByConditions($conditions, $removeLink = true)
function removeByPkvs($pkvs, $removeLink = true)
function removeAll()
function removeAllWithLinks()
function enableLinks($links = null)
function enableLink($linkName)
function disableLinks($links = null)
function disableLink($linkName)
function clearLinks()
function relink()
function & getLink($linkName)
function & getLinkTable($linkName)
function existsLink($name)
function createLink($defines, $type)
function removeLink($linkName)
function checkRowData(& $row, $skip = 0) {
function getLastValidation($info = null) {
function newInsertId() {
function execute($sql, $inputarr = false)
function qinto($sql, $params = null)
function parseWhere($where, $args = null)
function _parseWhereArray($where)
function _parseWhereString($where, $args = null)
function _parseWhereQfield($matches)
function qstr($value)
function qfield($fieldName, $tableName = null)
function qfields($fieldsName, $tableName = null, $returnArray = false)
function getWhere($conditions, $queryLinks = true) {
function flushMeta()
function _setUpdatedTimeFields(& $row) {
function _setCreatedTimeFields(& $row) {
function _prepareMeta($flushCache = false) {
function _beforeCreate(& $row)
function _beforeCreateDb(& $row)
function _afterCreateDb(& $row)
function _beforeUpdate(& $row)
function _beforeUpdateDb(& $row)
function _afterUpdateDb(& $row)
function _beforeRemove(& $row)
function _afterRemoveDb($row)
function _beforeRemoveDbByPkv($pkv)
function _afterRemoveDbByPkv($pkv)
function _updateCounterCache(& $row)