本文整理汇总了PHP中dibi::update方法的典型用法代码示例。如果您正苦于以下问题:PHP dibi::update方法的具体用法?PHP dibi::update怎么用?PHP dibi::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dibi
的用法示例。
在下文中一共展示了dibi::update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __set
public function __set($name, $value)
{
if (!array_key_exists($name, $this->vars)) {
dibi::insert("configs", array('name' => $name, 'value' => $value))->execute();
return $this->vars[$name] = $value;
} else {
if ($this->vars[$name] == $value) {
return $value;
}
dibi::update("configs", array('value' => $value))->where('name=%s', $name)->execute();
return $this->vars[$name] = $value;
}
}
示例2: date_default_timezone_set
<h1>Using Fluent Syntax | dibi</h1>
<?php
require_once 'Nette/Debug.php';
require_once '../dibi/dibi.php';
date_default_timezone_set('Europe/Prague');
dibi::connect(array('driver' => 'sqlite', 'database' => 'data/sample.sdb'));
$id = 10;
$record = array('title' => 'Super product', 'price' => 318, 'active' => TRUE);
// SELECT ...
dibi::select('product_id')->as('id')->select('title')->from('products')->innerJoin('orders')->using('(product_id)')->innerJoin('customers USING (customer_id)')->orderBy('title')->test();
// -> SELECT [product_id] AS [id] , [title] FROM [products] INNER JOIN [orders]
// USING (product_id) INNER JOIN customers USING (customer_id) ORDER BY [title]
// SELECT ...
echo dibi::select('title')->as('id')->from('products')->fetchSingle();
// -> Chair (as result of query: SELECT [title] AS [id] FROM [products])
// INSERT ...
dibi::insert('products', $record)->setFlag('IGNORE')->test();
// -> INSERT IGNORE INTO [products] ([title], [price], [active]) VALUES ('Super product', 318, 1)
// UPDATE ...
dibi::update('products', $record)->where('product_id = %d', $id)->test();
// -> UPDATE [products] SET [title]='Super product', [price]=318, [active]=1 WHERE product_id = 10
// DELETE ...
dibi::delete('products')->where('product_id = %d', $id)->test();
// -> DELETE FROM [products] WHERE product_id = 10
// custom commands
dibi::command()->update('products')->where('product_id = %d', $id)->set($record)->test();
// -> UPDATE [products] SET [title]='Super product', [price]=318, [active]=1 WHERE product_id = 10
dibi::command()->truncate('products')->test();
// -> TRUNCATE [products]
示例3: update
/**
* basic update specified by $id
*
* @param int $id
* @param array $data
* @return DibiResult
*/
public function update($id, array $data)
{
return dibi::update(static::TABLE, $data)->where('id = %i', $id)->execute();
}
示例4: activate
/**
* activate user identified by token
*
* @param string $token
* @return bool false => expired, true => approved
* @throws TokenExpiredException
*/
public static function activate($token)
{
$row = dibi::select("id, DATEDIFF(NOW(), registered) <= %i AS not_expired", self::EXPIRY_DAYS)->from(self::TABLE)->where("token = %s", $token)->fetch();
// invalid token
if (!$row) {
throw new TokenExpiredException();
} else {
// all good => approve user
if ($row->not_expired) {
dibi::update(self::TABLE, array('approved' => 1))->where("id = %i", $row->id)->execute();
// expired => delete him
} else {
dibi::delete(self::TABLE)->where("token = %s", $token)->execute();
return false;
}
}
return true;
}
示例5: findAllStrings
public function findAllStrings()
{
$files = array();
foreach (self::$dirs as $dir) {
$path = realpath(APP_DIR . "\\{$dir}\\");
$files = array_merge($files, $this->getFiles($path, array('php', 'phtml')));
}
// z tohto suoru nechceme sosat
$files = array_diff($files, array(__FILE__));
$phrases = array();
$patterns = array("#{_[\"\\']((?:\\\\?+.)*?)[\"\\']#s", "#\\s+(?:\\\$this->translate|_)\\([\\'|\"](.*)[\\'|\"]\\)#Us", "#flashMessage\\([\\'|\"](.*)[\\'|\"][,|\\)|(\\s+\\.\\s+)]#Us");
foreach ($files as $file) {
foreach ($patterns as $pattern) {
preg_match_all($pattern, file_get_contents($file), $matches);
foreach ($matches[1] as $val) {
// $phrases[] = $val;
$phrases[$val] = substr($file, strlen(WWW_DIR) + 1);
}
}
}
$phrasesArray = $phrases;
$phrases = array_unique(array_keys($phrases));
if (!isset($this->dictionary)) {
$this->buildDictionary();
}
$loadedPhrases = array_keys($this->dictionary);
$allPhrases = array_unique(array_merge($phrases, $loadedPhrases));
$oldOrForm = array_diff($loadedPhrases, $phrases);
$newPhrases = array_diff($phrases, $loadedPhrases);
// dump($phrasesArray);
// dump($loadedPhrases);
// dump($allPhrases);
// dump($oldOrForm);
// dump($newPhrases);
// $oldOrForm
// $newPhrases = array_diff_key(1)
// dump($newPhrases);
// dump();
// insert new phrases in 1 query
if (count($newPhrases) > 0) {
$files = $this->filterArray($newPhrases, $phrasesArray);
// dump($files);die();
$data = array('msg_id' => array_keys($files), 'file' => array_values($files));
dibi::query('INSERT INTO %n %m', self::TABLE, $data);
}
if (count($oldOrForm) > 0) {
foreach ($oldOrForm as $phrase) {
dibi::update(self::TABLE, array('oldOrForm' => 1))->where('msg_id = %s', $phrase)->execute();
}
}
if ($this->debug) {
// dump($phrases);
echo '<b>';
echo count($allPhrases) . " phrases together<br>";
echo count($files) . " files matched<br>";
echo count($phrases) . " phrases found to be translated<br>";
echo count($newPhrases) . " new phrases found:</b><br>" . join('<br>', $newPhrases);
echo '<b>' . count($oldOrForm) . " phrases not found but exist in dictionary => possibly unused or from form:</b><br>" . join('<br>', $oldOrForm);
}
// aby sa refresol slovnik
$cache = Environment::getCache('dictionary');
unset($cache['data']);
$this->buildDictionary();
}