本文整理汇总了PHP中Db::row方法的典型用法代码示例。如果您正苦于以下问题:PHP Db::row方法的具体用法?PHP Db::row怎么用?PHP Db::row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db::row方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_site_name
function get_site_name()
{
global $db_config;
$db = new Db($db_config);
$settings = $db->row("SELECT * FROM `settings`");
return $settings['site_name'];
}
示例2: dispatch
public function dispatch()
{
$row = Db::row("SELECT empresas.id_empresas\n , empresas.nombre\n , empresas.direccion_1\n , empresas.direccion_2\n , empresas.ciudad\n , empresas.estado\n , empresas.cod_postal\n , empresas.web\n , empresas.tel_oficina\n , empresas.tel_fax\n , empresas.logo\n , paises.id_paises\n , paises.nombre AS pais\n FROM empresas\n LEFT JOIN paises ON paises.id_paises = empresas.id_paises\n WHERE empresas.id_empresas = '{$this->idEmpresas}'");
$direccion = String::format("{%s}{ %s}", $row['direccion_1'], $row['direccion_2']);
$lugar = String::format("{%s}{, %s}{ (%s)}", $row['ciudad'], $row['estado'], $row['cod_postal']);
$this->data = array('nombre' => $row['nombre'], 'direccion_1' => $row['direccion_1'], 'direccion_2' => $row['direccion_2'], 'direccion' => $direccion, 'lugar' => $lugar, 'id_paises' => $row['id_paises'], 'pais' => $row['pais'], 'ciudad' => $row['ciudad'], 'estado' => $row['estado'], 'cod_postal' => $row['cod_postal'], 'tel_oficina' => $row['tel_oficina'], 'tel_fax' => $row['tel_fax'], 'web' => $row['web'], 'logo' => $row['logo']);
parent::dispatch();
}
示例3: dispatch
public function dispatch()
{
$row = Db::row("SELECT personas.id_personas\n , personas.nombre\n , personas.apellido\n , personas.correo\n , personas.usuario\n , personas.cargo\n , personas.tel_oficina\n , personas.tel_oficina_int\n , personas.tel_celular\n , personas.tel_fax\n , personas.tel_casa\n , personas.foto\n , empresas.id_empresas\n , empresas.nombre AS empresa\n FROM personas\n INNER JOIN empresas ON empresas.id_empresas = personas.id_empresas\n WHERE personas.id_personas = '{$this->idPersonas}'");
$nombreCompleto = String::format("{%s}{ %s}", $row['nombre'], $row['apellido']);
$telOficinaCompleto = String::format("{%s}{ x%s}", $row['tel_oficina'], $row['tel_oficina_int']);
$this->data = array('nombre_completo' => $nombreCompleto, 'nombre' => $row['nombre'], 'apellido' => $row['apellido'], 'cargo' => $row['cargo'], 'correo' => $row['correo'], 'usuario' => $row['usuario'], 'tel_oficina_completo' => $telOficinaCompleto, 'tel_oficina' => $row['tel_oficina'], 'tel_oficina_int' => $row['tel_oficina_int'], 'tel_celular' => $row['tel_celular'], 'tel_fax' => $row['tel_fax'], 'tel_casa' => $row['tel_casa'], 'foto' => $row['foto']);
parent::dispatch();
}
示例4: start
public static function start()
{
if (self::$started) {
return;
}
self::read();
self::$started = true;
$result = Db::row("SELECT u.id_personas\n , CONCAT(u.nombre, ' ', u.apellido) AS nombre\n FROM personas u\n WHERE u.usuario = '" . self::$usuario . "'\n AND u.contrasena = '" . self::$contrasena . "'\n LIMIT 1");
self::$id = $result['id_personas'];
self::$nombre = $result['nombre'];
}
示例5: find
public static function find($where = array())
{
$sql = "select * from pages";
$args = array();
if (count($where)) {
$clause = array();
foreach ($where as $key => $value) {
$clause[] = '`' . $key . '` = ?';
$args[] = $value;
}
$sql .= " where " . implode(' and ', $clause);
}
return static::extend(Db::row($sql, $args));
}
示例6: find
public static function find($where = array())
{
$sql = "select * from users";
$args = array();
if (isset($where['hash'])) {
$sql .= " where md5(concat(`id`, `email`, `password`)) = ? limit 1";
$args[] = $where['hash'];
// reset clause
$where = array();
}
if (count($where)) {
$clause = array();
foreach ($where as $key => $value) {
$clause[] = '`' . $key . '` = ?';
$args[] = $value;
}
$sql .= " where " . implode(' and ', $clause);
}
return Db::row($sql, $args);
}
示例7: start
public static function start()
{
// run gc
static::gc();
// get session id
$name = Config::get('session.name', 'anchorcms');
static::$id = Cookie::get($name);
if (static::$id === false) {
Log::info('Session cookie not found: ' . $name);
static::$id = Str::random(32);
}
// load session data
$sql = "select data from sessions where id = ? and ip = ? and ua = ? limit 1";
$args = array(static::$id, Input::ip_address(), Input::user_agent());
if ($session = Db::row($sql, $args)) {
static::$data = unserialize($session->data);
} else {
// Session not found regenerate ID
static::$id = Str::random(32);
Db::insert('sessions', array('id' => static::$id, 'date' => date(DATE_ISO8601), 'ip' => Input::ip_address(), 'ua' => Input::user_agent(), 'data' => serialize(static::$data)));
}
}
示例8: Db
if($insert > 0){
}
}
}
}*/
$tag = $_POST['tag'];
require_once 'config/Db.php';
$db = new Db();
$response = array("tag" => $tag, "error" => FALSE);
if ($tag == 'login') {
$user = filter_input(INPUT_POST, 'user');
$pass = filter_input(INPUT_POST, 'pass');
$cek_user = "SELECT * FROM tblUser WHERE username = :user AND password = :pass";
$dt = array('user' => $user, 'pass' => md5($pass));
$res = $db->row($cek_user, $dt);
if ($res > 0) {
$id_user = $res['idtblUser'];
$level = $res['level'];
$query_up = "UPDATE tblUser SET status = :status WHERE idtblUser = :iduser";
$dt = array('status' => '1', 'iduser' => $id_user);
$query_up = $db->query($query_up, $dt);
if ($level == '1') {
$data = "SELECT * FROM tblPasien WHERE idTblUser = :iduser";
$dt = array('iduser' => $id_user);
$data = $db->row($data, $dt);
if ($data > 0) {
$par_cek = 1;
} else {
$par_cek = 0;
}
示例9: array
Fetching Row:
</h4>
<pre>
<code class="lang-php">
<?php
$DB->row("SELECT * FROM fruit WHERE name=? and color=?",array('apple','red'));
?>
</code>
</pre>
<p>
Result:
</p>
<pre>
<code class="lang-php">
<?php
var_export($DB->row("SELECT * FROM fruit WHERE name=? and color=?", array('apple', 'red')));
?>
</code>
</pre>
<h4>
Fetching single:
</h4>
<pre>
<code class="lang-php">
<?php
$DB->single("SELECT color FROM fruit WHERE name=? ",array('watermelon'));
?>
</code>
</pre>
<p>
Result:
示例10: intval
LIMIT ' . $Config['TopicsPerPage']))));
}
// Get the infomation of current user
$CurUserInfo = null;
//当前用户信息,Array,以后判断是否登陆使用if($CurUserID)
$CurUserRole = 0;
$CurUserID = intval(GetCookie('UserID'));
$CurUserExpirationTime = intval(GetCookie('UserExpirationTime'));
$CurUserCode = GetCookie('UserCode');
if ($CurUserExpirationTime > $TimeStamp && $CurUserExpirationTime < $TimeStamp + 2678400 && $CurUserID && $CurUserCode) {
$TempUserInfo = array();
if ($MCache) {
$TempUserInfo = $MCache->get(MemCachePrefix . 'UserInfo_' . $CurUserID);
}
if (!$TempUserInfo) {
$TempUserInfo = $DB->row("SELECT * FROM " . $Prefix . "users WHERE ID = :UserID", array("UserID" => $CurUserID));
if ($MCache && $TempUserInfo) {
$MCache->set(MemCachePrefix . 'UserInfo_' . $CurUserID, $TempUserInfo, 86400);
}
}
//Using hash_equals() in the future
if ($TempUserInfo && HashEquals(md5($TempUserInfo['Password'] . $TempUserInfo['Salt'] . $CurUserExpirationTime . $SALT), $CurUserCode)) {
$CurUserName = $TempUserInfo['UserName'];
$CurUserRole = $TempUserInfo['UserRoleID'];
$CurUserInfo = $TempUserInfo;
} else {
SetCookies(array('UserID' => '', 'UserExpirationTime' => '', 'UserCode' => ''), 1);
$CurUserID = 0;
}
unset($TempUserInfo);
} elseif ($CurUserExpirationTime || $CurUserID || $CurUserCode) {
示例11: dirname
define('DS', DIRECTORY_SEPARATOR);
define('BASE_DIR', dirname(__FILE__) . DS);
define('SITE_ROOT', '');
require_once BASE_DIR . 'Libs' . DS . 'autoload.php';
require_once BASE_DIR . 'configs' . DS . 'incs.php';
require_once BASE_DIR . 'helpers' . DS . 'incs.php';
//-------------------------------------------------------
Util::$template_path = BASE_DIR . 'templates' . DS;
//-------------------------------------------------------
$notFound = false;
$db = new Db($db_config);
$sql_menus = "SELECT `id`, `menu_title`, `page_title`, `slug` FROM `pages` WHERE `active` = 1 AND `is_menu` = 1 AND `is_home` = 0";
$sql_home = "SELECT `id`, `menu_title`, `page_title`, `slug` FROM `pages` WHERE `active` = 1 AND `is_menu` = 1 AND `is_home` = 1";
$slug = get_slug();
$home = $db->row($sql_home);
if ($slug == "") {
if (!is_null($home)) {
$slug = $home['slug'];
} else {
$notFound = true;
}
}
$sql_page = sprintf("SELECT * FROM `pages` WHERE `slug` = '%s'", $db->escString($slug));
$page = $db->row($sql_page);
if (is_null($page)) {
$notFound = true;
}
//-------------------------------------------------------
if ($notFound) {
Response::SetHeader($_SERVER['SERVER_PROTOCOL'], '404 Page Not Found');
示例12: add
public static function add()
{
$post = Input::post(array('title', 'slug', 'description', 'html', 'css', 'js', 'status', 'field', 'comments'));
$errors = array();
if (empty($post['title'])) {
$errors[] = 'Please enter a title';
}
if (empty($post['description'])) {
$errors[] = 'Please enter a description';
}
if (empty($post['html'])) {
$errors[] = 'Please enter your html';
}
if (empty($post['slug'])) {
$post['slug'] = preg_replace('/\\W+/', '-', trim(strtolower($post['title'])));
}
// check for duplicate slug
$sql = "select id from posts where slug = ?";
if (Db::row($sql, array($post['slug']))) {
$errors[] = 'A post with the same slug already exists, please change your post slug.';
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
$custom = array();
if (is_array($post['field'])) {
foreach ($post['field'] as $keylabel => $value) {
list($key, $label) = explode(':', $keylabel);
$custom[$key] = array('label' => $label, 'value' => $value);
}
}
// remove from update
unset($post['field']);
$post['custom_fields'] = json_encode($custom);
// set creation date
$post['created'] = time();
// set author
$user = Users::authed();
$post['author'] = $user->id;
Db::insert('posts', $post);
Notifications::set('success', 'Your new post has been added');
return true;
}
示例13: read
function read()
{
if ($this->lt->item = Db::row($this->lt->model['table'], $this->control->id)) {
return true;
}
if ($_ENV['CrudbadIdCallback']) {
call_user_func($_ENV['CrudbadIdCallback']);
}
}
示例14: array
//-------------------------------------------------------
Util::$template_path = ADMIN_DIR . 'templates' . DS;
//-------------------------------------------------------
$id = Request::Get('id');
if (is_null($id)) {
Response::Redirect('index.php');
}
$emsg = "";
$errors = array();
$db = new Db($db_config);
$sql_page = "SELECT * FROM `pages` WHERE `id` = %d";
$sql_page = sprintf($sql_page, (int) $db->escString($id));
$filepath = BASE_DIR . 'assets' . DS . 'images' . DS;
if (Request::Post('delete_page_key') == "1") {
$sql = "DELETE FROM `pages` WHERE `id` = %d";
$page = $db->row($sql_page);
$imagename = $page['image'];
if (file_exists($filepath . $imagename)) {
unlink($filepath . $imagename);
}
$sql = sprintf($sql, (int) $db->escString($id));
if ($db->execute($sql)) {
Response::Redirect("index.php?done=delete");
} else {
$emsg = "Could not delete page. Something went wrong. Please try again.";
}
}
if (Request::Post('upload_key') == "1") {
if (isset($_FILES['image']) && $_FILES['image']['name'] != "") {
$image = $_FILES['image'];
$extension = strtolower(substr($image['name'], -4));
示例15: find
public static function find($where = array())
{
$sql = "\n\t\t\tselect\n\n\t\t\t\tposts.id,\n\t\t\t\tposts.title,\n\t\t\t\tposts.slug,\n\t\t\t\tposts.description,\n\t\t\t\tposts.html,\n\t\t\t\tposts.css,\n\t\t\t\tposts.js,\n\t\t\t\tposts.created,\n\t\t\t\tposts.custom_fields,\n\t\t\t\tcoalesce(users.real_name, posts.author) as author,\n\t\t\t\tcoalesce(users.bio, '') as bio,\n\t\t\t\tposts.status,\n\t\t\t\tposts.comments\n\n\t\t\tfrom posts \n\t\t\tleft join users on (users.id = posts.author) \n\t\t";
$args = array();
if (count($where)) {
$clause = array();
foreach ($where as $key => $value) {
$clause[] = 'posts.' . $key . ' = ?';
$args[] = $value;
}
$sql .= " where " . implode(' and ', $clause);
}
return static::extend(Db::row($sql, $args));
}