本文整理汇总了PHP中Connection::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::query方法的具体用法?PHP Connection::query怎么用?PHP Connection::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTables
/**
* Returns list of tables.
*/
public function getTables()
{
$tables = array();
foreach ($this->connection->query('SELECT * FROM cat') as $row) {
if ($row[1] === 'TABLE' || $row[1] === 'VIEW') {
$tables[] = array('name' => $row[0], 'view' => $row[1] === 'VIEW');
}
}
return $tables;
}
示例2: setUp
/**
* @inheritdoc
*/
protected function setUp()
{
$this->schemas = (require __DIR__ . '/db/schemas.php');
$this->fixtures = (require __DIR__ . '/db/fixtures.php');
$this->connection = Manager::getConnection(['driver' => 'pdo_sqlite']);
foreach ($this->schemas as $table => $definition) {
$this->connection->query('CREATE TABLE ' . $table . ' (' . join(', ', $definition) . ')');
}
foreach ($this->fixtures as $table => $fixtures) {
foreach ($fixtures as $data) {
$this->connection->insert($table, $data);
}
}
}
示例3: load
public function load(Connection $connection)
{
if (!$connection->isConnected) {
$connection->Connect();
}
if (!$connection->query($this->medicationQuery)) {
return false;
} else {
$result = null;
$medication = null;
while ($result = $connection->getObject()) {
$medication = new Medication();
$medication->setCommonDose($result->commonDose);
$medication->setGenericName($result->genericName);
$medication->setRoute($result->route);
$medication->setUnit($result->unit);
$medication->setMedicationID($result->medicationId);
$medication->setActive($result->active);
$medication->setConfirmed($result->confirmed);
$medication->setConfirmedBy($result->confirmedBy);
array_push($this->medicationList, $medication);
}
}
return true;
}
示例4: testGetAffectedRowsDelete
public function testGetAffectedRowsDelete()
{
$this->createTable();
$statement = $this->connection->query("INSERT INTO cat (name, colour) VALUES (?, ?)", array('Nennek', 'black'));
$statement = $this->connection->query("DELETE FROM cat WHERE id = ?", array(1));
$this->assertEquals(1, $this->connection->getAffectedRows());
}
示例5: Connection
function __construct()
{
if (!isset($_SESSION['username'])) {
if (isset($_POST['login'])) {
$connection = new Connection();
$this->username = $connection->validate_string($_POST['username']);
$password = $connection->validate_string($_POST['password']);
$query = "\n\t\t\t\tSELECT p_password, p_barcode\n\t\t\t\tFROM people\n\t\t\t\tWHERE p_username = '{$this->username}';";
$connection->query($query);
if ($connection->result_size() == 1) {
$row = $connection->fetch_row();
if ($row[0] == $password && $password != "") {
$_SESSION['username'] = $this->username;
$_SESSION['barcode'] = $row[1];
$_SESSION['user'] = true;
$_SESSION['admin'] = true;
} else {
$this->loginError();
exit(0);
}
} else {
$this->loginError();
exit(0);
}
} else {
$this->printLoginScreen();
exit(0);
}
}
$this->username = $_SESSION['username'];
$this->barcode = $_SESSION['barcode'];
$this->user = $_SESSION['user'];
$this->admin = $_SESSION['admin'];
}
示例6: getUsers
function getUsers()
{
$db = new Connection(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$result = $db->query('SELECT name FROM users');
while ($row = mysql_fetch_assoc($result)) {
echo $row['name'] . '<br>';
}
}
示例7: save
public function save()
{
$oCon = new Connection();
if ($this->iPostID == 0) {
$sSQL = "INSERT INTO tbposts (PostContent, TopicID, MemberID) VALUES (\n '" . $this->sPostContent . "',\n '" . $this->iTopicID . "',\n '" . $this->iMemberID . "')";
$bResult = $oCon->query($sSQL);
if ($bResult == true) {
$this->iPostID = $oCon->getInsertID();
} else {
die($sSQL . " did not run");
}
} else {
$sSQL = 'UPDATE tbposts SET Active = ' . $this->iActive . ' WHERE PostID=' . $this->iPostID;
$bResult = $oCon->query($sSQL);
}
$oCon->close();
}
示例8: remove
public function remove($id_mensaje)
{
$db = new Connection();
$dateLeaving = date("m.d.y");
$query = "UPDATE MENSAJE SET fecha_baja = {$dateLeaving} where id_mensaje = {$id_mensaje}";
$results = $db->query($query) or die('Error dando de baja el mensaje: ' . mysqli_error($this->db));
$db->close();
}
示例9: query
/**
* @return Result
*/
private function query($args)
{
$res = $this->connection->query($args);
foreach ($this->setups as $setup) {
call_user_func_array([$res, array_shift($setup)], $setup);
}
return $res;
}
示例10: exists
/**
* @param null $sql
*
* @return bool
*/
public function exists($sql = null)
{
if (null == $sql) {
$sql = $this->prepareExists();
}
$result = $this->_connection->query($sql);
return $result->one() != null;
}
示例11: getForeignKeys
/**
* Returns metadata for all foreign keys in a table.
*/
public function getForeignKeys($table)
{
/* Not for multi-column foreign keys */
$keys = array();
foreach ($this->connection->query("\n\t\t\tSELECT\n\t\t\t\ttc.constraint_name AS name,\n\t\t\t\tkcu.column_name AS local,\n\t\t\t\tccu.table_name AS table,\n\t\t\t\tccu.column_name AS foreign\n\t\t\tFROM\n\t\t\t\tinformation_schema.table_constraints AS tc\n\t\t\t\tJOIN information_schema.key_column_usage AS kcu USING(constraint_catalog, constraint_schema, constraint_name)\n\t\t\t\tJOIN information_schema.constraint_column_usage AS ccu USING(constraint_catalog, constraint_schema, constraint_name)\n\t\t\tWHERE\n\t\t\t\tconstraint_type = 'FOREIGN KEY'\n\t\t\t\tAND\n\t\t\t\ttc.table_name = {$this->connection->quote($table)}\n\t\t\tORDER BY\n\t\t\t\tkcu.ordinal_position\n\t\t") as $row) {
$keys[] = (array) $row;
}
return $keys;
}
示例12: load
public function load($iGenreID)
{
$oCon = new Connection();
$sSQL = "SELECT GenreID, GenreName, DisplayOrder \n\t\t\tFROM tbgenres \n\t\t\tWHERE GenreID = " . $iGenreID;
$oResultSet = $oCon->query($sSQL);
$aRow = $oCon->fetchArray($oResultSet);
$this->iGenreID = $aRow['GenreID'];
$this->sGenreName = $aRow['GenreName'];
$this->iDisplayOrder = $aRow['DisplayOrder'];
$sSQL = "SELECT RecordID\n\t\t\tFROM tbrecords \n\t\t\tWHERE GenreID = " . $iGenreID;
$oResultSet = $oCon->query($sSQL);
while ($aRow = $oCon->fetchArray($oResultSet)) {
$iRecordID = $aRow["RecordID"];
$oRecord = new Record();
$oRecord->load($iRecordID);
$this->aRecords[] = $oRecord;
}
$oCon->close();
}
示例13: query
/**
* @param string $table
* @param mixed $hash
* @param Context\Query $context
* @return \Riverline\DynamoDB\Collection
*/
public function query($table, $hash, Context\Query $context = null)
{
$collection = new Collection();
do {
try {
$items = $this->connection->query($table, $hash, $context);
$collection->merge($items);
if ($items->more()) {
$context = $items->getNextContext();
} else {
// End
break;
}
} catch (\Riverline\DynamoDB\Exception\ProvisionedThroughputExceededException $e) {
// Continue
}
} while (true);
return $collection;
}
示例14: save
public function save()
{
$oCon = new Connection();
if ($this->iCategoryID == 0) {
$sSQL = 'INSERT INTO tbcategory (CategoryName, CategoryDesc)
VALUES(
"' . $this->sCategoryName . '",
"' . $this->sCategoryDesc . '")';
$bResult = $oCon->query($sSQL);
if ($bResult == true) {
$this->iCategoryID = $oCon->getInsertID();
} else {
die($sSQL . " did not run");
}
} else {
$sSQL = 'UPDATE tbcategory SET Active = ' . $this->iActive . ' WHERE CategoryID=' . $this->iCategoryID;
$bResult = $oCon->query($sSQL);
}
$oCon->close();
}
示例15: selectAll
function selectAll()
{
$claseConexion = new Connection();
$resultado = $claseConexion->query("\n SELECT Id_horario, Hora_ini, Hora_fin, Dia, Id_materia, Id_aula\n FROM horario");
$listaHorario = array();
while ($row = $resultado->fetch(PDO::FETCH_ASSOC)) {
$objResultado = $this->rowToDto($row);
$listaHorario[] = $objResultado;
}
return $listaHorario;
}