public function testConnection() { $c = new MySQLConnection(); try { $c->getMysqli(); } catch (\Littled\Exception\ConfigurationUndefinedException $ex) { $this->assertEquals('MYSQL_HOST not found in app settings.', $ex->getMessage()); } $rs = $c->fetchRecords("select * from promotion order by id asc"); $this->assertCount(4, $rs, "Number of records returned by fetchRecords()"); $row = $rs[0]; $this->assertEquals('MAY14', $row->code, "Test field from first row."); }
/** * class constructor * @param string $param_prefix A value to prepended to all of the core parameters of the base class. */ function __construct($param_prefix = '') { parent::__construct(); $this->page = new IntegerContentFilter("Page", $param_prefix . self::PAGE_PARAM, null, null, self::COOKIE_NAME()); $this->listingsLength = new IntegerContentFilter("Page length", $param_prefix . self::LISTINGS_LENGTH_PARAM, null, null, self::COOKIE_NAME()); $this->next = new StringContentFilter("Next", $param_prefix . self::NEXT_OPERATION_PARAM, '', 16, self::COOKIE_NAME()); $this->displayListings = new BooleanContentFilter("Display listings", $param_prefix . self::FILTER_PARAM, false, null, self::COOKIE_NAME()); $this->referringURL = ''; }
/** * Returns a MySQLi object using either default connection settings, or settings passed in. * @param string $host * @param string $user * @param string $password * @param string $schema * @return \mysqli * @throws ConfigurationUndefinedException */ public static function getMysqli($host = '', $user = '', $password = '', $schema = '') { $c = MySQLConnection::getConnectionSettings($host, $user, $password, $schema); return new \mysqli($c->host, $c->user, $c->password, $c->schema); }
function __construct() { parent::__construct(); $this->id = new IntegerInput("id", "ID", null, true); }