本文整理汇总了PHP中ActiveRecord::query方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::query方法的具体用法?PHP ActiveRecord::query怎么用?PHP ActiveRecord::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exit
$offset = 0;
$rowamount = (int) $config->get('iface.rowamount');
$start = 1;
if (isset($_GET["start"])) {
$offset = ($_GET["start"] - 1) * $rowamount;
$start = $_GET["start"];
}
print $display->header();
if (!preg_match('/^\\d+$/', $_GET['id'])) {
print $display->error("You hacker!");
print $display->footer();
exit(1);
}
try {
$d = Domain::find($_GET['id']);
$result = ActiveRecord::query("SELECT COUNT(*) AS count FROM records WHERE domain_id={$d->id}");
$rCount = (int) $result[0]['count'];
if ($rCount > $rowamount) {
$findResult = Record::find('all', array('limit' => "{$rowamount}", 'offset' => "{$offset}", 'conditions' => 'domain_id = ' . Record::quote($d->id), 'order' => 'name'));
} else {
$findResult = Record::find('all', array('conditions' => 'domain_id = ' . Record::quote($d->id), 'order' => 'name'));
}
} catch (Exception $e) {
print $e->getMessage();
print $display->footer();
exit(0);
}
?>
<script language="JavaScript" src="http://www.mattkruse.com/javascript/datadumper/datadumper.js"></script>
示例2: array
#
$qFindResult = Queue::find('all', array('conditions' => 'commit_date IS NULL'));
print '<div class="header">' . Queue::count_all_pendingDomains() . ' pending domain changes</div><br>';
if (count($qFindResult) > 0) {
print '<table><tr><th>Function</th><th>Name</th><th>Type</th><th>By</th></tr>';
foreach ($qFindResult as $entry) {
foreach ($entry->queue_item_domains as $item) {
print '<tr class="domain"><td>' . $item->function . '</td><td>' . $item->name . '</td><td>' . $item->type . '</td><td>' . $item->user_id . '</td></tr>';
}
}
print '</table><br><br>';
}
#
#
#
$result = ActiveRecord::query("SELECT COUNT(*) AS count FROM domains");
$dCount = (int) $result[0]['count'];
print '<div class="header">' . $dCount . ' domains found</div><br>';
if ($dCount > $rowamount) {
$condition = NULL;
switch ($type) {
case "reverse":
if (!preg_match('/^\\d/', $char)) {
die("Reverse only works with numeric values");
}
/*
* select char 'j' at a reverse domain where k and l are optional
* reverse domain: abc.def.ghi.jkl.in-addr.arpa
* select * from domains where name REGEXP '\\.j[[:digit:]]{0,2}\\.in-addr\\.arpa'
*/
$condition = "name REGEXP '\\\\." . $char . "[[:digit:]]{0,2}\\\\.in-addr.arpa'";
示例3: reverse_start_chars
public static function reverse_start_chars()
{
$results = ActiveRecord::query("SELECT SUBSTRING(d.name, 1, 1) AS 'chr' FROM domains d WHERE d.name REGEXP '[[:digit:]]{1,3}\\.in-addr\\.arpa' GROUP BY 1");
$return = array();
foreach ($results as $result) {
array_push($return, $result['chr']);
}
return $return;
}
示例4: foreach
$tables[] = $table;
}
/* end hack for PDO */
foreach ($tables as $table_row) {
$table_name = current($table_row);
$table_vanity_name = $table_name;
if (AR_PREFIX && AR_PREFIX != '') {
$table_vanity_name = preg_replace('/^' . AR_PREFIX . '/', '', $table_name);
}
if (is_array($AR_TABLES)) {
if (!in_array($table_vanity_name, $AR_TABLES)) {
continue;
}
}
$class_name = ActiveRecordInflector::classify($table_vanity_name);
$columns_q = ActiveRecord::query("DESC {$table_name}");
$columns = array();
foreach ($columns_q as $column_row) {
$columns[] = "'" . $column_row['Field'] . "'";
if ($column_row['Key'] == 'PRI') {
$primary_key = $column_row['Field'];
}
}
if (!file_exists($stub_models_dir . $class_name . ".php")) {
$gen_file = $stub_template;
$gen_file = preg_replace('/{\\$class_name}/', $class_name, $gen_file);
file_put_contents($stub_models_dir . $class_name . ".php", $gen_file);
}
$gen_file = $template;
$gen_file = preg_replace('/{\\$ar_dir}/', $this_dir, $gen_file);
$gen_file = preg_replace('/{\\$table_name}/', $table_name, $gen_file);