Пример #1
0
 public function execute()
 {
     $table = new PhamePost();
     $conn_r = $table->establishConnection('r');
     $where_clause = $this->buildWhereClause($conn_r);
     $order_clause = $this->buildOrderClause($conn_r);
     $limit_clause = $this->buildLimitClause($conn_r);
     $data = queryfx_all($conn_r, 'SELECT * FROM %T e %Q %Q %Q', $table->getTableName(), $where_clause, $order_clause, $limit_clause);
     $posts = $table->loadAllFromArray($data);
     return $posts;
 }
Пример #2
0
 protected function loadPage()
 {
     $table = new PhamePost();
     $conn_r = $table->establishConnection('r');
     $where_clause = $this->buildWhereClause($conn_r);
     $order_clause = $this->buildOrderClause($conn_r);
     $limit_clause = $this->buildLimitClause($conn_r);
     $data = queryfx_all($conn_r, 'SELECT * FROM %T p %Q %Q %Q', $table->getTableName(), $where_clause, $order_clause, $limit_clause);
     $posts = $table->loadAllFromArray($data);
     if ($posts) {
         // We require these to do visibility checks, so load them unconditionally.
         $blog_phids = mpull($posts, 'getBlogPHID');
         $blogs = id(new PhameBlogQuery())->setViewer($this->getViewer())->withPHIDs($blog_phids)->execute();
         $blogs = mpull($blogs, null, 'getPHID');
         foreach ($posts as $post) {
             if (isset($blogs[$post->getBlogPHID()])) {
                 $post->setBlog($blogs[$post->getBlogPHID()]);
             }
         }
     }
     return $posts;
 }
<?php

$table = new PhamePost();
$conn_w = $table->establishConnection('w');
$iterator = new LiskMigrationIterator($table);
foreach ($iterator as $post) {
    $id = $post->getID();
    echo pht('Adding mail key for Post %d...', $id);
    echo "\n";
    queryfx($conn_w, 'UPDATE %T SET mailKey = %s WHERE id = %d', $table->getTableName(), Filesystem::readRandomCharacters(20), $id);
}