本文整理汇总了PHP中Mysql::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Mysql::select方法的具体用法?PHP Mysql::select怎么用?PHP Mysql::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mysql
的用法示例。
在下文中一共展示了Mysql::select方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find
/**
* Basic find models, uses $where as array of conditions
* $order and $limit to make query
*
* @param array $where
* @param string $order
* @param string $limit
* @return \Collection
*/
public static function find(array $where = null, $order = null, $limit = null)
{
if ($sql = Mysql::prepareSelect(static::getTable(), $where, $order, $limit)) {
return Mysql::select($sql, get_called_class());
}
return null;
}
示例2: getUserId
* User: shaoting
* Date: 15/7/26
* Time: 下午5:25
*/
include "../Visitor.php";
$_GET['userId'] = getUserId();
$KeyList = array('userId', 'footprintId');
foreach ($KeyList as $k => $v) {
if (!isset($_GET[$v])) {
$res = ['ok' => 0, 'error' => "param invalid "];
echo json_encode($res);
die;
}
}
$mysql = new Mysql();
$result = $mysql->select("*", "footprint", "`footId`", "'{$_GET['footprintId']}'");
if ($result) {
if ($result['userId'] == $_GET['userId']) {
$myMemcache = new MyMemcache();
$footprintId = $result['id'];
$removeFootprint = "delete from footprint where id={$footprintId}";
//echo $removeFootprint;
$mysql->query($removeFootprint);
$myMemcache->delete($_GET['userId'] . "foot" . $result['footId']);
if ($myMemcache->get("like" . $result['footId']) && $myMemcache->get("like" . $result['footId']) == 1) {
//$removeFoot="delete from foot where id={$result['footId']}";
//$mysql->query($removeFoot);
}
echo json_encode(['ok' => 1]);
} else {
echo json_encode(['ok' => 0, 'error' => "no permission"]);
示例3: Mysql
$res = ['ok' => 0, 'error' => $error];
echo json_encode($res);
die;
}
if (isset($key)) {
$key .= ",`" . $v . "`";
$value .= ",'" . mysql_real_escape_string($_POST[$v]) . "'";
} else {
$key = "`" . $v . "`";
$value = "'" . mysql_real_escape_string($_POST[$v]) . "'";
}
}
$mysql = new Mysql();
//连接数据库
$userName = $_POST['userName'];
$result = $mysql->select("*", 'user', '`username`', "'{$userName}'");
if (!$result) {
$mysql->replace("user", "{$key}", "{$value}");
$userId = mysql_insert_id();
$mysql->close();
} else {
$res = ['ok' => 0, 'error' => 'username existed'];
echo json_encode($res);
die;
}
$myMemcache = new MyMemcache();
$expireTime = 7 * 24 * 3600;
$token = md5(uniqid(rand(), TRUE));
$myMemcache->set("u" . $userId, $token, $expireTime);
$myMemcache->set($token, $userId, $expireTime);
$myMemcache->close();
示例4: json_encode
<?php
/**
* Created by PhpStorm.
* User: shaoting
* Date: 15/7/26
* Time: 下午9:57
*/
include "../Visitor.php";
$userId = getUserId();
$mysql = new Mysql();
$result = $mysql->select("*", "`user_regular`", "`user_id`", "{$userId}");
if ($result) {
//echo "SELECT * FROM user_regular u inner join regular r WHERE r.id=u.regular_id and u.user_id={$userId}";
$regular_array = $mysql->query_array("select * from (SELECT u.*,r.host,r.threshold FROM user_regular u inner join regular r WHERE r.id=u.regular_id and u.user_id={$userId} order by time desc ) a group by host");
} else {
//echo "select * from (SELECT *,count(r.id) count FROM user_regular u inner join regular r WHERE r.id=u.regular_id group by r.id)a limit 10";
//无规则时返回大家用的最多的规则
$regular_array = $mysql->query_array("select * from (SELECT u.*,r.host,r.threshold,count(r.id) count FROM user_regular u inner join regular r WHERE r.id=u.regular_id group by r.id)a group by host order by time desc limit 10");
}
foreach ($regular_array as $v) {
$regular = new Regular($v);
$regulars[] = $regular;
}
$res = [ok => 1, data => $regulars];
echo json_encode($res);
示例5: fetchAll
public static function fetchAll()
{
return Mysql::select('SELECT * FROM music');
}
示例6: select
{
public function select()
{
echo 'The class "', __METHOD__, '" was initiated!<br />';
}
}
class Mssql extends Database
{
public function connect()
{
echo 'The class "', __METHOD__, '" was initiated! User : ' . $this->user . ' Pass : ' . $this->pass . '<br />';
}
public function select()
{
echo 'The class "', __METHOD__, '" was initiated!<br />';
}
}
$db = new Mysql();
$db->authentication('root', 'root');
$db->connect();
$db->select();
echo "<hr>";
$db = new Postgresql();
$db->authentication('root', 'root');
$db->connect();
$db->select();
echo "<hr>";
$db = new Mssql();
$db->authentication('ali', 'root');
$db->connect();
$db->select();