本文整理汇总了PHP中LocalRepo::getSlaveDb方法的典型用法代码示例。如果您正苦于以下问题:PHP LocalRepo::getSlaveDb方法的具体用法?PHP LocalRepo::getSlaveDb怎么用?PHP LocalRepo::getSlaveDb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalRepo
的用法示例。
在下文中一共展示了LocalRepo::getSlaveDb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchFileMetadata
/**
* Helper function: do the actual database query to fetch file metadata.
*
* @param string $key key
* @param $readFromDB: constant (default: DB_SLAVE)
* @return boolean
*/
protected function fetchFileMetadata( $key, $readFromDB = DB_SLAVE ) {
// populate $fileMetadata[$key]
$dbr = null;
if ( $readFromDB === DB_MASTER ) {
// sometimes reading from the master is necessary, if there's replication lag.
$dbr = $this->repo->getMasterDb();
} else {
$dbr = $this->repo->getSlaveDb();
}
$row = $dbr->selectRow(
'uploadstash',
'*',
array( 'us_key' => $key ),
__METHOD__
);
if ( !is_object( $row ) ) {
// key wasn't present in the database. this will happen sometimes.
return false;
}
$this->fileMetadata[$key] = (array)$row;
return true;
}
示例2: fetchFileMetadata
/**
* Helper function: do the actual database query to fetch file metadata.
*
* @param $key String: key
* @return boolean
*/
protected function fetchFileMetadata($key)
{
// populate $fileMetadata[$key]
$dbr = $this->repo->getSlaveDb();
$row = $dbr->selectRow('uploadstash', '*', array('us_key' => $key), __METHOD__);
if (!is_object($row)) {
// key wasn't present in the database. this will happen sometimes.
return false;
}
$this->fileMetadata[$key] = array('us_user' => $row->us_user, 'us_key' => $row->us_key, 'us_orig_path' => $row->us_orig_path, 'us_path' => $row->us_path, 'us_size' => $row->us_size, 'us_sha1' => $row->us_sha1, 'us_mime' => $row->us_mime, 'us_media_type' => $row->us_media_type, 'us_image_width' => $row->us_image_width, 'us_image_height' => $row->us_image_height, 'us_image_bits' => $row->us_image_bits, 'us_source_type' => $row->us_source_type, 'us_timestamp' => $row->us_timestamp, 'us_status' => $row->us_status);
return true;
}