当前位置: 首页>>代码示例>>PHP>>正文


PHP Db::fetchRow方法代码示例

本文整理汇总了PHP中Db::fetchRow方法的典型用法代码示例。如果您正苦于以下问题:PHP Db::fetchRow方法的具体用法?PHP Db::fetchRow怎么用?PHP Db::fetchRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Db的用法示例。


在下文中一共展示了Db::fetchRow方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFetchRowCallsPdoWithSqlAndParams

 public function testFetchRowCallsPdoWithSqlAndParams()
 {
     $sql = 'SELECT * FROM `test_table` WHERE id = ? LIMIT 1';
     $sqlParameters = [1];
     $tableData = ['id' => 5];
     $mockPdoStatement = $this->createMock(\PDOStatement::class);
     $this->mockPdo->expects($this->once())->method('prepare')->with($sql)->willReturn($mockPdoStatement);
     $mockPdoStatement->expects($this->once())->method('execute')->with($sqlParameters);
     $mockPdoStatement->expects($this->once())->method('fetch')->willReturn($tableData);
     $this->assertEquals($tableData, $this->db->fetchRow($sql, $sqlParameters));
 }
开发者ID:starweb,项目名称:starlit-db,代码行数:11,代码来源:DbTest.php

示例2: getVideo

 /**
  * Загружает видео из базы данных по ID
  * @param $id
  * @return array|null
  * @throws Exception
  */
 protected function getVideo($id)
 {
     $video = $this->db->fetchRow("SELECT * FROM video WHERE id = :id LIMIT 1", ['id' => $id]);
     if (empty($video)) {
         throw new Exception("Not found video");
     }
     return $video;
 }
开发者ID:alexboo,项目名称:traffics-task2,代码行数:14,代码来源:App.php

示例3: onePagina

 public static function onePagina($idPagina, $idioma = null)
 {
     if (is_null($idioma)) {
         $idioma = Translate::locale();
     }
     $result = Db::fetchRow(Db::select(array('inmuebles_paginas_contenidos.inmueble_pagina_contenido_id', 'inmuebles_paginas_contenidos.idioma', 'inmuebles_paginas_contenidos.nombre', 'inmuebles_paginas_contenidos.titulo', 'inmuebles_paginas_contenidos.url', 'inmuebles_paginas.inmueble_pagina_id', 'inmuebles_paginas.codigo', 'inmuebles_paginas.tipo', 'inmuebles_paginas.posicion'), 'inmuebles_paginas_contenidos', array('inmuebles_paginas.inmueble_pagina_id' => $idPagina, 'inmuebles_paginas_contenidos.idioma' => $idioma), null, 1, array('inmuebles_paginas', array('inmuebles_paginas.inmueble_pagina_id' => 'inmuebles_paginas_contenidos.inmueble_pagina_id'))));
     $contenido = new Inmuebles_Paginas_Contenidos();
     if ($result) {
         $contenido->found(true);
         $contenido->import($result);
     }
     return $contenido;
 }
开发者ID:joksnet,项目名称:php-old,代码行数:13,代码来源:Contenidos.php

示例4: query

 public function query()
 {
     $this->found = false;
     if (!isset($this->values['id'])) {
         return false;
     }
     $values = Db::fetchRow(Db::select('*', $this->table, array($this->index => $this->values['id']), null, 1));
     if ($values) {
         $this->import($values);
         $this->found = true;
     }
     return $values ? true : false;
 }
开发者ID:joksnet,项目名称:php-old,代码行数:13,代码来源:Model.php

示例5: get

 /**
  * @param integer $id
  * @return boolean
  */
 public function get($id)
 {
     if (null === $this->identifier) {
         throw new Exception('Identifier not found.');
     }
     $result = $this->db->fetchRow($this->db->select('*', $this->table, array($this->identifier => $id)));
     if ($result) {
         foreach ($result as $name => $value) {
             $this->{":{$name}"} = $value;
         }
     }
     $this->hash = Model::hash($this->properties);
     return (bool) $result;
 }
开发者ID:joksnet,项目名称:php-old,代码行数:18,代码来源:Model.php

示例6: die

<?php

$root = '.';
include_once "{$root}/config.php";
include_once "{$root}/common.php";
if (!isset($_GET['pid'])) {
    die('Missing parameter');
}
$pid = (int) $_GET['pid'];
if (!Session::$logged) {
    header("Location: {$config['root']}signin/?next={$config['root']}dd/projects/{$pid}/delete/");
}
$title = __('ProjectsDeleteTitle');
$project = Db::fetchRow("SELECT name, description, uid\n     FROM projects\n     WHERE pid = '{$pid}'");
if ($project) {
    $name = $project['name'];
    $description = $project['description'];
    if ($project['uid'] == Session::_('uid')) {
        $access = true;
    }
}
if (!empty($_POST)) {
    if ($pid) {
        Db::query("DELETE FROM projects\n             WHERE pid = '{$pid}'");
    }
    header("Location: {$config['root']}dd/projects/");
}
require_once "{$root}/themes/{$theme}/ddprojectsdelete.php";
开发者ID:joksnet,项目名称:php-old,代码行数:28,代码来源:ddprojectsdelete.php

示例7: update

 public function update($id, $data)
 {
     $db = new Db($this->subgridConfig, $this->statusVariables);
     $oldData = $db->fetchRow($id);
     $fields = $this->subgridConfig->fields();
     $dbData = array();
     $languageData = array();
     $languages = ipContent()->getLanguages();
     foreach ($fields as $field) {
         if (empty($field['field']) || $field['field'] == $this->subgridConfig->idField() || isset($field['allowUpdate']) && !$field['allowUpdate'] || !empty($field['type']) && $field['type'] == 'Tab' || !empty($field['ignoreDb'])) {
             continue;
         }
         $fieldObject = $this->subgridConfig->fieldObject($field);
         $fieldObject->beforeUpdate($id, $oldData, $data);
         //the same event for both: multilingual and non multilingual fields. Each field may store it's multilingual state from constructor and act differently on this event if needed. $oldData is not very correct in multilingual context. But that's still the bets way to go.
         if (empty($field['multilingual'])) {
             $fieldData = $fieldObject->updateData($data);
             if (!is_array($fieldData)) {
                 throw new \Ip\Exception("updateData method in class " . esc(get_class($fieldObject)) . " has to return array.");
             }
             $dbData = array_merge($dbData, $fieldData);
         } else {
             foreach ($languages as $language) {
                 $tmpData = $data;
                 if (isset($data[$field['field'] . '_' . $language->getCode()])) {
                     $tmpData[$field['field']] = $data[$field['field'] . '_' . $language->getCode()];
                 }
                 $fieldObject = $this->subgridConfig->fieldObject($field);
                 $fieldData = $fieldObject->updateData($tmpData);
                 if (!is_array($fieldData)) {
                     throw new \Ip\Exception("createData method in class " . esc(get_class($fieldObject)) . " has to return array.");
                 }
                 if (empty($languageData[$language->getCode()])) {
                     $languageData[$language->getCode()] = array();
                 }
                 $languageData[$language->getCode()] = array_merge($languageData[$language->getCode()], $fieldData);
             }
         }
     }
     if ($this->subgridConfig->updateFilter()) {
         $dbData = call_user_func($this->subgridConfig->updateFilter(), $id, $dbData);
     }
     if ($this->subgridConfig->isMultilingual() && $this->subgridConfig->updateLanguageFilter()) {
         $languageData = call_user_func($this->subgridConfig->updateLanguageFilter(), $id, $languageData);
     }
     $this->updateDb($this->subgridConfig->rawTableName(), $dbData, $id);
     if (!empty($languageData)) {
         foreach ($languageData as $languageCode => $rawData) {
             $translationExists = ipDb()->selectRow($this->subgridConfig->rawLanguageTableName(), '*', array($this->subgridConfig->languageCodeField() => $languageCode, $this->subgridConfig->languageForeignKeyField() => $id));
             if (!$translationExists) {
                 $insertData = $rawData;
                 $insertData[$this->subgridConfig->languageCodeField()] = $languageCode;
                 $insertData[$this->subgridConfig->languageForeignKeyField()] = $id;
                 ipDb()->insert($this->subgridConfig->rawLanguageTableName(), $insertData);
             }
             $this->updateDb($this->subgridConfig->rawTableName(), $rawData, $id, $languageCode);
         }
     }
     foreach ($fields as $field) {
         $this->subgridConfig->fieldObject($field)->afterUpdate($id, $oldData, $data);
     }
 }
开发者ID:Umz,项目名称:ImpressPages,代码行数:62,代码来源:Actions.php

示例8: die

<?php

$root = '.';
include_once "{$root}/config.php";
include_once "{$root}/common.php";
if (!isset($_GET['pid'])) {
    die('Missing parameter');
}
$pid = (int) $_GET['pid'];
if (!Session::$logged) {
    header("Location: {$config['root']}signin/?next={$config['root']}dd/projects/{$pid}/");
}
$project = Db::fetchRow("SELECT pid, uid, name, description, public\n     FROM projects\n     WHERE pid = '{$pid}'");
$title = empty($project) ? __('ProjectNotFound') : $project['name'];
if (!empty($project)) {
    $access = false;
    if ($project['public']) {
        $access = true;
    } elseif ($project['uid'] == Session::_('uid')) {
        $access = true;
    } else {
        $usersAccess = Db::fetchPairs("SELECT uid, aid\n             FROM projects_access\n             WHERE pid = '{$pid}'\n               AND uid != 0");
        if (!empty($usersAccess)) {
            $access = isset($usersAccess[Session::_('uid')]) ? true : false;
        }
    }
    $names = Db::fetchAssoc("SELECT n.nid, n.name, n.description, u.uid, u.email\n         FROM projects_names n\n         INNER JOIN users u ON u.uid = n.uid\n         WHERE n.pid = '{$pid}'");
}
require_once "{$root}/themes/{$theme}/ddprojectsview.php";
开发者ID:joksnet,项目名称:php-old,代码行数:29,代码来源:ddprojectsview.php

示例9: select

 protected function select($id)
 {
     $this->user = Db::fetchRow("SELECT users.id_user AS id\n                  , users.name\n                  , users.username\n                  , users.location\n                  , users.description\n                  , users.image\n                  , users.url\n                  , users.token\n                  , users.secret\n                  , users.address\n                  , users.x\n                  , users.y\n                  , users.sex\n                  , users.age\n                  , users.modified\n                  , users.created\n             FROM twcensus_users AS users\n             WHERE id_user = '{$id}'");
     return $this->user;
 }
开发者ID:joksnet,项目名称:php-old,代码行数:5,代码来源:index.php

示例10: __

}
$title = __('SignInTitle');
$error = array();
if (isset($_GET['email']) && isEmail($_GET['email'])) {
    $email = $_GET['email'];
}
if (!empty($_POST)) {
    $email = $_POST['email'];
    $password = $_POST['password'];
    if (!isEmail($email)) {
        $error['email'] = true;
    }
    if (strlen($password) < 6) {
        $error['password'] = true;
    }
    if (empty($error)) {
        $data = Db::fetchRow("SELECT uid, email, password\n             FROM users\n             WHERE email = '{$email}'\n               AND password = MD5('{$password}')");
        if (empty($data)) {
            $error['signin'] = true;
        }
    }
    if (empty($error) && $data) {
        Session::register($data);
        if (isset($_POST['next'])) {
            header("Location: {$_POST['next']}");
        } else {
            header("Location: {$config['root']}dd/");
        }
    }
}
require_once "{$root}/themes/{$theme}/signin.php";
开发者ID:joksnet,项目名称:php-old,代码行数:31,代码来源:signin.php

示例11: updateForm

 public function updateForm($id)
 {
     $db = new Db($this->subgridConfig, $this->statusVariables);
     $form = new \Ip\Form();
     $form->addAttribute('autocomplete', 'off');
     $curData = $db->fetchRow($id);
     $curDataMultilingual = array();
     if ($this->subgridConfig->isMultilingual()) {
         //fetch multilingual data
         $languages = ipContent()->getLanguages();
         foreach ($languages as $language) {
             $langDb = new Db($this->subgridConfig, $this->statusVariables);
             $langDb->setDefaultLanguageCode($language->getCode());
             $curDataMultilingual[$language->getCode()] = $langDb->fetchRow($id);
         }
     }
     foreach ($this->subgridConfig->fields() as $key => $fieldData) {
         if (isset($fieldData['allowUpdate']) && !$fieldData['allowUpdate']) {
             continue;
         }
         if (!empty($fieldData['type']) && $fieldData['type'] == 'Tab') {
             //tabs (fieldsets)
             $title = '';
             if (!empty($fieldData['label'])) {
                 $title = $fieldData['label'];
             }
             if ($key == 0) {
                 $fieldsets = $form->getFieldsets();
                 $fieldset = $fieldsets[0];
                 $fieldset->setLabel($title);
             } else {
                 $fieldset = new \Ip\Form\Fieldset($title);
                 $form->addFieldset($fieldset);
             }
             $fieldset->addAttribute('id', 'autoGridTabId' . rand(0, 100000000000));
             if ($key == 0) {
                 $fieldset->addAttribute('class', 'tab-pane active');
             } else {
                 $fieldset->addAttribute('class', 'tab-pane');
             }
         } else {
             //fields
             if (!empty($fieldData['multilingual'])) {
                 $languages = ipContent()->getLanguages();
                 foreach ($languages as $language) {
                     $tmpFieldData = $fieldData;
                     $field = $this->updateField($tmpFieldData, $curDataMultilingual[$language->getCode()]);
                     $field->setName($field->getName() . '_' . $language->getCode());
                     if ($field) {
                         $field->setLabel($field->getLabel() . ' ' . $language->getAbbreviation());
                         $form->addField($field);
                     }
                 }
             } else {
                 $field = $this->updateField($fieldData, $curData);
                 if ($field) {
                     $form->addField($field);
                 }
             }
         }
     }
     $field = new \Ip\Form\Field\Hidden(array('name' => $this->subgridConfig->idField(), 'value' => $id));
     $form->addField($field);
     $field = new \Ip\Form\Field\Hidden(array('name' => 'method', 'value' => 'update'));
     $form->addField($field);
     $field = new \Ip\Form\Field\HiddenSubmit();
     $form->addField($field);
     if (count($form->getFieldsets()) > 1) {
         $form->addClass('tab-content');
     }
     if ($this->subgridConfig->updateFormFilter()) {
         $form = call_user_func($this->subgridConfig->updateFormFilter(), $form);
     }
     return $form;
 }
开发者ID:Umz,项目名称:ImpressPages,代码行数:75,代码来源:Display.php


注:本文中的Db::fetchRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。