本文整理汇总了PHP中sql::select方法的典型用法代码示例。如果您正苦于以下问题:PHP sql::select方法的具体用法?PHP sql::select怎么用?PHP sql::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sql
的用法示例。
在下文中一共展示了sql::select方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLimit
public function testLimit()
{
self::assertEquals('select * from t limit 1', sql::select(sql::ALL)->from('t')->limit(1)->toString(Nano::db()));
self::assertEquals('select * from t limit 20, 10', sql::select(sql::ALL)->from('t')->limit(10, 20)->toString(Nano::db()));
self::assertEquals('select * from t limit 0, 5', sql::select(sql::ALL)->from('t')->limitPage(1, 5)->toString(Nano::db()));
self::assertEquals('select * from t limit 5, 5', sql::select(sql::ALL)->from('t')->limitPage(2, 5)->toString(Nano::db()));
self::assertEquals('select * from t limit 10, 5', sql::select(sql::ALL)->from('t')->limitPage(3, 5)->toString(Nano::db()));
}
示例2: loadCache
protected static function loadCache()
{
$result = array();
$rows = self::fetchThis(sql::select('*')->from(self::NAME)->order(Nano::db()->quoteName('order')));
foreach ($rows as $row) {
$result[$row->name] = $row;
}
return $result;
}
示例3: createQuery
/**
* @return sql_query
* @param string $class
* @param string $alias
*/
protected static function createQuery($class, $alias = null)
{
$name = constant($class . '::NAME');
$prefix = ($alias ? $alias : $name) . '.';
return sql::select($prefix . '*')->from($alias ? array($alias => $name) : $name);
}
示例4: __call
/**
* Use it to do some convenient queries.
*
* @param string $funcName the function name to be called
* @param array $funcArgs the params
* @access public
* @return object the dao object self.
*/
public function __call($funcName, $funcArgs)
{
$funcName = strtolower($funcName);
/* findByxxx, xxx as will be in the where. */
if (strpos($funcName, 'findby') !== false) {
$this->setMode('magic');
$field = str_replace('findby', '', $funcName);
if (count($funcArgs) == 1) {
$operator = '=';
$value = $funcArgs[0];
} else {
$operator = $funcArgs[0];
$value = $funcArgs[1];
}
$this->sqlobj = sql::select('%s')->from('%s')->where($field, $operator, $value);
return $this;
} elseif (strpos($funcName, 'fetch') !== false) {
$max = str_replace('fetch', '', $funcName);
$stmt = $this->query();
$rows = array();
$key = isset($funcArgs[0]) ? $funcArgs[0] : '';
$i = 0;
while ($row = $stmt->fetch()) {
$key ? $rows[$row->{$key}] = $row : ($rows[] = $row);
$i++;
if ($i == $max) {
break;
}
}
return $rows;
} else {
/* Create the max counts of sql class methods, and then create $arg0, $arg1... */
for ($i = 0; $i < SQL::MAX_ARGS; $i++) {
${"arg{$i}"} = isset($funcArgs[$i]) ? $funcArgs[$i] : null;
}
$this->sqlobj->{$funcName}($arg0, $arg1, $arg2);
return $this;
}
}
示例5: select
/**
* @return sql_select
*/
public function select()
{
return sql::select();
}
示例6: loadCache
protected static function loadCache()
{
$result = array();
$query = sql::select('s.*')->from(array('s' => self::NAME))->innerJoin(array('c' => Setting_Category::NAME), 's.setting_category_id = c.setting_category_id')->order('c.' . self::db()->quoteName('order'))->order('s.' . self::db()->quoteName('order'));
$rows = self::fetchThis($query);
foreach ($rows as $row) {
$category = Setting_Category::getById($row->setting_category_id)->name;
if (isset($result[$category])) {
$result[$category][$row->name] = $row;
} else {
$result[$category] = array($row->name => $row);
}
}
return $result;
}
示例7: listar2
public function listar2()
{
//con tablegetway y zend.db.sql
/*$lista = $this->tableGateway->select(function (Select $select) {
$select->where->like('nombre', 'kev%');
});*/
$adapter = $this->tableGateway->getAdapter();
$sql = new sql($adapter);
$select = $sql->select()->from('ta_usuario')->where(array('va_nombre' => 'kevin'));
//where('nombre=kevin');//
//$select->from('usuario');
//$select->where(array('nombre' => 'kevin'));
$selectString = $sql->getSqlStringForSqlObject($select);
$results = $adapter->query($selectString, $adapter::QUERY_MODE_EXECUTE);
//$sql = new Sql($this->tableGateway->getAdapter());
/* $spec = function (Where $where) {
$where->like('nombre','kev%');
};*/
// $lista = $sql->select()->from('usuario');//->where->like('nombre', 'kev%');
$returnArray = array();
foreach ($results as $result) {
$returnArray[] = $result;
}
var_dump($returnArray);
exit;
}