本文整理汇总了PHP中Select类的典型用法代码示例。如果您正苦于以下问题:PHP Select类的具体用法?PHP Select怎么用?PHP Select使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Select类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetLanguageSelect
function GetLanguageSelect($FolderName, &$WarningCollector, $SelectedLanguage)
{
$Select = false;
$FolderHandle = @opendir($FolderName);
if (!$FolderHandle) {
$WarningCollector->Add("We had a problem opening the languages folder");
} else {
$Languages = array();
$Key = 0;
// Loop through each file
while (false !== ($Item = readdir($FolderHandle))) {
$RecordItem = true;
if ($Item == "." || $Item == ".." || is_dir($FolderName . $Item)) {
// do nothing
} else {
// Retrieve languages names
$FileParts = explode(".", $Item);
$Languages[] = $FileParts[0];
if ($FileParts[0] == $SelectedLanguage) {
$Key = count($Languages);
}
}
}
$Select = new Select();
$Select->Name = "Language";
for ($i = 0; $i < count($Languages); $i++) {
$Select->AddOption($Languages[$i], $Languages[$i]);
}
$Select->SelectedIndex = $Key;
}
return $Select;
}
示例2: loadRandom
public function loadRandom()
{
$select = new Select(self::$db);
$select->from(self::$table, "*")->where("`state` =" . self::$db->getSQ(), array(1))->rand()->limit(1);
$row = self::$db->selectRow($select);
return $this->init($row);
}
示例3: getAllOnID
protected static function getAllOnID($table, $id)
{
$select = new Select(self::$db);
$select->from($table, "*")->where("`id` = ?", array($id));
$data = self::$db->select($select);
return $data;
}
示例4: getPerfil
public function getPerfil()
{
$element = new Select('perfil');
$element->setLabel('Perfil');
$element->setAttributes(array('id' => 'perfil', 'class' => 'form-control'));
return $element;
}
示例5: testConstructorTableNameSelect
/**
* @covers Select::newSelect
* @uses Select::__construct
* @uses Select::getQuery
*/
public function testConstructorTableNameSelect()
{
$select = new Select('TableName');
$assertSql = 'SELECT * FROM TableName';
// Assert
$this->assertEquals($select->getQuery(), $assertSql);
}
示例6: loadRandom
public function loadRandom()
{
$select = new Select(self::$db);
$select->from(self::$table, "*")->rand()->limit(1);
$row = self::$db->selectRow($select);
return $this->init($row);
}
示例7: doLogin
function doLogin() {
$this->save("login");
if (empty($this->messages)) {
$select = new Select("users");
$select->add(Exp::eq("username", $this->login["username"]));
$user = DB::unique($select);
if (empty($user)) {
$this->addMsgMessage("error.fieldNotFound", "login.username");
Msg::save($this->messages);
Apu::redirect("login");
}
if ($user["password"] != $this->login["password"]) {
$this->addMsgMessage("error.fieldNotFound", "login.password");
Msg::save($this->messages);
Apu::redirect("login");
}
$date = new Date();
Session::save(LOGIN_SCOPE, $user, "user");
Session::save(LOGIN_SCOPE, $date, "last_access");
$this->remove();
Apu::redirect("frame");
} else {
Msg::save($this->messages);
Apu::redirect("login");
}
}
示例8: __construct
/**
* __construct
*
* @param string $caption caption
* @param string $name name
* @param integer $size size
* @param integer $value value unix timestamp
* @param boolean $showtime true to show time, false for date only
*/
public function __construct($caption, $name, $size = 2, $value = 0, $showtime = true)
{
parent::__construct($caption, '');
$value = (int) $value;
$value = $value > 0 ? $value : time();
$datetime = getdate($value);
$date = new DateSelect('', $name . '[date]', $size, $value);
$date->setAttribute('id', $name . '-date');
$this->addElement($date);
if ($showtime) {
$timearray = array();
for ($i = 0; $i < 24; ++$i) {
for ($j = 0; $j < 60; $j = $j + 10) {
$key = $i * 3600 + $j * 60;
$timearray[$key] = $j != 0 ? $i . ':' . $j : $i . ':0' . $j;
}
}
ksort($timearray);
$timeselect = new Select('', $name . '[time]', $datetime['hours'] * 3600 + 600 * ceil($datetime['minutes'] / 10));
$timeselect->setAttribute('id', $name . '-time');
$timeselect->addOptionArray($timearray);
$timeselect->setClass('span2');
$this->addElement($timeselect);
} else {
$this->addElement(new Hidden($name . '[time]', 0));
}
}
示例9: testCompileWithNumericValue
public function testCompileWithNumericValue()
{
$field = new Select("test", "Test", array("test", "blue"), array("useNumericValue" => true));
$expected = "<label for=\"test\">Test</label><select name=\"test\" ><option value=\"0\" selected=\"selected\">test</option><option value=\"1\">blue</option></select>";
$value = $field->compile(0);
$this->assertEquals($expected, $value);
}
示例10: getImgOnID
public static function getImgOnID($id)
{
$select = new Select(self::$db);
$select->from(self::$table, "*")->where("`product_id` = " . self::$db->getSQ(), array($id));
$data = self::$db->select($select);
$images = ObjectDB::buildMultiple(__CLASS__, $data);
return $images;
}
示例11: it_renders_with_options_the_full_html
/** @test */
public function it_renders_with_options_the_full_html()
{
$field = new Select('test', 'Test', ['values' => ['miro' => 'test']]);
$field->render();
$options = $field->options();
$this->assertCount(1, $options);
$this->assertInstanceOf(Option::class, $options[0]);
}
示例12: getElementsCount
/**
* @param Select $select
* @return array
*/
public function getElementsCount(Select $select)
{
$select->setLimit(null);
$select->setOffset(null);
$select->setColumns(array('COUNT(*)'));
$db = new DbGateway();
return $db->execute($select, \PDO::FETCH_COLUMN);
}
示例13: __listTables
protected function __listTables($cache = TRUE)
{
if ($cache && sizeof($this->tables)) {
return $this->tables;
}
$select = new Select('information_schema.TABLES');
$select->where(array(array('field' => 'TABLE_SCHEMA', 'value' => $this->params['name'])));
return $this->tables = $select->execute('\\apf\\db\\mysql5\\Table', $smart = FALSE);
}
示例14: getStudentsOnGroupID
public static function getStudentsOnGroupID($group_id)
{
$select = new Select(self::$db);
$select->from(self::$table, "*")->where("`group_id` = ?", array($group_id));
$data = self::$db->select($select);
$students = ObjectDB::buildMultiple(__CLASS__, $data);
//foreach ($groups as $g) $g->postHandling();
return $students;
}
示例15: render
/**
* render
*
* @return string
*/
public function render()
{
$editor_handler = \XoopsEditorHandler::getInstance();
$editor_handler->allowed_editors = $this->allowed_editors;
$option_select = new Select("", $this->name, $this->value);
$onchangeCode = '"if(this.options[this.selectedIndex].value.length > 0 ){window.document.forms.' . $this->form->getName() . '.submit();}"';
$option_select->set('onchange', $onchangeCode);
$option_select->addOptionArray($editor_handler->getList($this->nohtml));
$this->addElement($option_select);
return parent::render();
}