本文整理汇总了PHP中object::fetchRow方法的典型用法代码示例。如果您正苦于以下问题:PHP object::fetchRow方法的具体用法?PHP object::fetchRow怎么用?PHP object::fetchRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::fetchRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculateViaSQL
/**
*
* execute a SQL query in the form SELECT $formula as Result
*
* @param model class $model
* @param string $formula A string that is a formula like 2+3
* @return mixed. The array of queries
*/
public function calculateViaSQL(Model $model, $formula)
{
$formula = "Select " . $formula . " as Result;";
$result = $this->dbo->fetchRow($formula);
if (empty($result)) {
return false;
} else {
return (string) $result[0]['Result'];
}
}
示例2: rs2xml
/**
* Creates XML from the ADODB record set
*
* @param object $rs - record set object
* @param bool $moveFirst - determines whether recordset is returned to first record
* @return string $xml - resulting xml
* @version V1.0 10 June 2006 (c) 2006 Rich Zygler ( http://www.boringguys.com/ ). All rights reserved.
*
* Released under both BSD license and Lesser GPL library license. You can choose which license
* you prefer.
*/
function rs2xml($rs, $moveFirst = false)
{
if (!$rs) {
printf(ADODB_BAD_RS, 'rs2xml');
return false;
}
$xml = '';
$totalRows = 0;
$totalRows = $rs->numrows();
$domxml = new DOMDocument('1.0', 'utf-8');
$root = $domxml->appendChild($domxml->createElement('rows'));
$root->setAttribute('total-rows', $totalRows);
$row_count = 1;
while ($line = $rs->fetchRow()) {
$row = $root->appendChild($domxml->createElement('row'));
foreach ($line as $col_key => $col_val) {
$col = $row->appendChild($domxml->createElement('column'));
$col->setAttribute('name', strtolower($col_key));
$col->appendChild($domxml->createTextNode($col_val));
}
$row_count++;
}
$domxml->formatOutput = true;
$xml = $domxml->saveXML();
$domxml = null;
if ($moveFirst) {
$rs->MoveFirst();
}
return $xml;
}
示例3: selectRow
/**
* Run a query and return a single row
*
* @param string $sql
* @return array
*/
function selectRow($sql)
{
$this->debug['queries']++;
$this->debug['actualQueries'][] = $sql;
$c = $this->db->fetchRow($sql);
return $c;
}
示例4: getVariable
/**
* get the mysql variable
*
* @access public
* @param string name variable name
* @return string variable
*/
function getVariable($name)
{
$sql = 'SHOW VARIABLES LIKE \'' . $name . '\'';
$res = $this->_db->queryF($sql);
while (list($key, $value) = $this->_db->fetchRow($res)) {
$variable[$key] = $value;
}
return $variable[$name];
}
示例5: read
/**
* Read a session from the database
*
* @param string &sess_id ID of the session
*
* @return array Session data
*/
function read($sess_id)
{
$sql = sprintf('SELECT sess_data FROM %s WHERE sess_id = %s', $this->db->prefix('session'), $this->db->quoteString($sess_id));
if (false != ($result = $this->db->query($sql))) {
if (list($sess_data) = $this->db->fetchRow($result)) {
return $sess_data;
}
}
return '';
}
示例6: getFootage
/**
* Load this object
* @since Version 3.10.0
* @return void;
*/
private function getFootage()
{
$data = $this->db->fetchRow("SELECT * FROM railcam_footage WHERE id = ?", $this->id);
$data['fileinfo'] = json_decode($data['fileinfo'], true);
$this->timeStamp = new DateTime($data['datestored']);
$this->setCamera(new Camera($data['railcam_id']));
$this->type = $data['type'];
$storageObject = new Storage($data['storage_id']);
$this->footageData = ["id" => $data['id'], "camera" => $this->cameraObject->getArray(), "type" => $this->type, "url" => ["original" => $storageObject->getWebUrl($data['fileinfo'])]];
return;
}
示例7: array
/**
* 获取所有的fields
*
* @access public
* @param string $table_name 数据表名
* @return array
*/
function get_fields($table_name)
{
$fields = array();
$result = $this->db->query("SHOW FIELDS FROM {$table_name}", 'SILENT');
if ($result) {
while ($row = $this->db->fetchRow($result)) {
$fields[] = $row['Field'];
}
}
return $fields;
}
示例8: __construct
/**
* Constructor
*
* @param array Options containing 'table', 'name'
*/
public function __construct(array $options = array())
{
// Initialize the options
$options = $this->_initialize($options);
// Mixin the KMixinClass
$this->mixin(new KMixinClass($this, 'Rowset'));
// Assign the classname with values from the config
$this->setClassName($options['name']);
// Set table object and class name
$this->_tableClass = 'com.' . $this->getClassName('prefix') . '.table.' . $this->getClassName('suffix');
$this->_table = isset($options['table']) ? $options['table'] : KFactory::get($this->_tableClass);
// Set the data
if (isset($options['data'])) {
$this->_data = $options['data'];
}
// Count the data
$this->resetCount();
// Instantiate an empty row to use for cloning later
$this->_emptyRow = $this->_table->fetchRow();
}
示例9: getCount
/**
* count objects matching a criteria
*
* @param object $criteria {@link CriteriaElement} to match
* @return int count of objects
* @access public
*/
function getCount($criteria = null)
{
$sql = 'SELECT COUNT(*) FROM ' . $this->_db->prefix($this->_dbtable);
if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
$sql .= ' ' . $criteria->renderWhere();
}
if (!($result =& $this->_db->query($sql))) {
return 0;
}
list($count) = $this->_db->fetchRow($result);
return $count;
}
示例10: getCount
/**
* Count the number of online users
*
* @param object $criteria {@link CriteriaElement}
*/
function getCount($criteria = null)
{
$sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('online');
if (is_object($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
$sql .= ' ' . $criteria->renderWhere();
}
if (!($result = $this->db->query($sql))) {
return false;
}
list($ret) = $this->db->fetchRow($result);
return $ret;
}
示例11: array
/**
* 获得用于验证身份的信息
*
* @access private
* @return string or boolean 成功返回用于登录短信服务的帐号信息,失败返回false。
*/
function get_login_info()
{
$sql = 'SELECT `code`, `value` FROM ' . $this->ecs->table('shop_config') . " WHERE `code` = 'sms_user_name' OR `code` = 'sms_password'";
$result = $this->db->query($sql);
$retval = array();
if (!empty($result)) {
while ($temp_arr = $this->db->fetchRow($result)) {
$retval[$temp_arr['code']] = $temp_arr['value'];
}
return base64_encode($retval['sms_user_name'] . "\t" . $retval['sms_password']);
}
return false;
}
示例12: calculateTotal
/**
* calculateTotal()
* Calculate totlas
* @access public
* @return type
*/
private function calculateTotal()
{
if (!$this->totalPages) {
$this->query = new \NG\Query();
$this->query->select("COUNT(*) as total")->from($this->table);
if (isset($this->where)) {
$this->query->where($this->where);
}
$result = $this->db->fetchRow($this->query->__toString());
$this->totalCount = $result['total'];
$this->totalPages = ceil($this->totalCount / $this->itemsPerPage);
}
return $this->totalPages;
}
示例13: write
/**
* Write a session to the database
*
* @param string $sess_id
* @param string $sess_data
*
* @return bool
**/
function write($sessionId, $data)
{
$sessionId = $this->db->quote($sessionId);
$data = $this->db->quote($data);
$time = time();
list($count) = $this->db->fetchRow($this->db->query("SELECT COUNT(*) FROM `{$this->tableName}` WHERE sess_id={$sessionId}"));
if ($count > 0) {
$sql = "UPDATE `{$this->tableName}` SET sess_updated={$time},sess_data={$data} WHERE sess_id={$sessionId}";
} else {
$ip = $this->db->quote($_SERVER['REMOTE_ADDR']);
$sql = "INSERT INTO `{$this->tableName}` (sess_id,sess_updated,sess_ip,sess_data) VALUES ({$sessionId},{$time},{$ip},{$data})";
}
return $this->db->queryF($sql);
}
示例14: write
/**
* Write a session to the database
*
* @param string $sess_id
* @param string $sess_data
*
* @return bool
**/
function write($sess_id, $sess_data)
{
global $HTTP_SERVER_VARS;
list($count) = $this->db->fetchRow($this->db->query("SELECT COUNT(*) FROM " . $this->db->prefix('session') . " WHERE sess_id='" . $sess_id . "'"));
if ($count > 0) {
$sql = sprintf("UPDATE %s SET sess_updated = %u, sess_data = '%s' WHERE sess_id = '%s'", $this->db->prefix('session'), time(), $sess_data, $sess_id);
} else {
$sql = sprintf("INSERT INTO %s (sess_id, sess_updated, sess_ip, sess_data) VALUES ('%s', %u, '%s', '%s')", $this->db->prefix('session'), $sess_id, time(), $HTTP_SERVER_VARS['REMOTE_ADDR'], $sess_data);
}
if (!$this->db->queryF($sql)) {
return false;
}
return true;
}
示例15: write
/**
* Write a session to the database
*
* @param string $sess_id
* @param string $sess_data
*
* @return bool
**/
function write($sess_id, $sess_data)
{
$sess_id = $this->db->quoteString($sess_id);
list($count) = $this->db->fetchRow($this->db->query("SELECT COUNT(*) FROM " . $this->db->prefix('session') . " WHERE sess_id=" . $sess_id));
if ($count > 0) {
$sql = sprintf('UPDATE %s SET sess_updated = %u, sess_data = %s WHERE sess_id = %s', $this->db->prefix('session'), time(), $this->db->quoteString($sess_data), $sess_id);
} else {
$sql = sprintf('INSERT INTO %s (sess_id, sess_updated, sess_ip, sess_data) VALUES (%s, %u, %s, %s)', $this->db->prefix('session'), $sess_id, time(), $this->db->quoteString($_SERVER['REMOTE_ADDR']), $this->db->quoteString($sess_data));
}
if (!$this->db->queryF($sql)) {
return false;
}
return true;
}