コード例 #1
0
 public function testFactoryReturnsDbTableSelectAdapter()
 {
     $table = new TestTable($this->_adapter);
     $paginator = Zend_Paginator::factory($table->select());
     $this->assertType('Zend_Paginator_Adapter_DbSelect', $paginator->getAdapter());
 }
コード例 #2
0
 public static function getTests()
 {
     return TestTable::instance()->getTests();
 }
コード例 #3
0
 /**
  * @brief function handling what the script does
  */
 protected function run(&$params)
 {
     /**
      * if you want to call a large amount of records you would use this
      * this allows you to query an array of parameters ie
      * array(
      * 'name'   => "richard", (if you wanted to a search for thing like) "%richard%"
      * 'active' => true
      * )
      */
     // the right way to get all records for large datasets
     write("example of queryEach");
     TestTable::queryEach(array(), function ($record) {
         $this->callback($record);
     });
     sleep(5);
     /**
      * this allows you to query and get all records
      * again using an array like above
      */
     write("example of queryRecords");
     $params = array('active' => true);
     // wrong way to get all records for large datasets
     $records = TestTable::queryRecords($params);
     write(print_r($records, true));
     sleep(5);
     /**
      * Example of querying on record ID
      */
     write("example of queryRecordID");
     $record = TestTable::queryRecordID($records[0]->id);
     write(print_r($record, true));
     sleep(5);
     /**
      * Example of creating a record
      */
     write("example of creating a new entry");
     $tt = new TestTable();
     $tt->name = "Some Guy";
     $tt->code = "some_guy";
     $tt->active = false;
     write("that entry before save");
     write(print_r($tt, true));
     $tt->storeRecord();
     sleep(5);
     write("that entry after save");
     write(print_r($tt, true));
     sleep(5);
     write("A look up of the new records using the queryEach");
     $params = array('name' => "some%", 'code' => "some_guy");
     TestTable::queryEach($params, function ($record) {
         $this->callback($record);
     });
 }
コード例 #4
0
 private function getExistingRecord()
 {
     $this->clearTable();
     $table = new TestTable();
     $table->setFirstname('Jane');
     $table->setLastname('Doe');
     $table->commit();
     return $table;
 }