本文整理匯總了PHP中mysql::executaSQL方法的典型用法代碼示例。如果您正苦於以下問題:PHP mysql::executaSQL方法的具體用法?PHP mysql::executaSQL怎麽用?PHP mysql::executaSQL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mysql
的用法示例。
在下文中一共展示了mysql::executaSQL方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: mysql
<?php
require_once 'classes/classe_bancodados.inc';
$bd = new mysql('localhost', 'root');
$bd->startTransaction();
$houveErro = false;
$bd->executaSQL("use cake;");
$execRet = $bd->executaSQL("insert into articles(title, body) values ('aluno 01', 'Rafael Pomar');");
if (!$execRet) {
$houveErro = true;
}
$execRet = $bd->executaSQL("insert into articles(title, body) values ('aluno 02', 'Rafael garcia');");
if (!$execRet) {
$houveErro = true;
}
$execRet = $bd->executaSQL("insert into articles(title, body) values ('aluno 03', 'carlos');");
if (!$execRet) {
$houveErro = true;
}
$execRet = $bd->executaSQL("insert into articles(title, body) values ('aluno 04', 'Deise');");
if (!$execRet) {
$houveErro = true;
}
if ($houveErro) {
echo "houve um erro";
$bd->ROLLBACK();
} else {
echo "sucesso, vamos gravar";
$bd->commit();
}
示例2: mysql
<?php
require_once 'classes/classe_bancodados.inc';
//class BD extends BancoDados{};
$bd = new mysql('localhost', 'root');
//$conn = $bd->GetConn();
$articles = $bd->executaSQL("SELECT * FROM cake.articles");
//var_dump($articles);
//die;
$line = '';
while ($obj = $articles->fetch_object()) {
$line .= $obj->id;
$line .= $obj->title;
$line .= $obj->body;
$line .= "<br>";
}
echo $line;
示例3: mysql
<?php
require_once 'classes/classe_bancodados.inc';
$bd = new mysql('localhost', 'root');
$articles = $bd->executaSQL("select * from cake.articles");
$line = '';
while ($obj = $articles->fetch_object()) {
$line .= $obj->id;
$line .= $obj->title;
$line .= $obj->body;
$line .= "<br>";
}
echo $line;
?>
示例4: mysql
<?php
require_once 'classes/classe_bancodados.inc';
$bd = new mysql('localhost', 'root');
$bd->startTransaction();
$houveErro = false;
$bd->executaSQL("use cake;");
$execRet = $bd->executaSQL("insert into articles(title, body) values ('aluno 05', 'Rafael atrasado');");
if (!$execRet) {
$houveErro = true;
}
$execRet = $bd->executaSQL("insert into articles(title, body) values ('aluno 06', 'Rafael sr.net');");
if (!$execRet) {
$houveErro = true;
}
$execRet = $bd->executaSQL("insert into articles(title, body) values ('aluno 07', 'Carlos faster');");
if (!$execRet) {
$houveErro = true;
}
$execRet = $bd->executaSQL("insert into articles(title, body) values ('aluno 08', 'Deise loka');");
if (!$execRet) {
$houveErro = true;
}
if ($houveErro) {
echo "Erro!";
$bd->ROLLBACK();
} else {
echo "Tudo OK!";
$bd->commit();
}
// echo $sql;
示例5: mysql
<?php
require_once 'classes/classe_bancodados.inc';
$bd = new mysql('localhost', 'root');
$bd->startTransaction();
$houveErro = false;
$bd->executaSQL("use cake;");
$execRet = $bd->executaSQL("INSERT INTO articles (title, body) VALUES ('Aluno 01', 'Rafael Pomar');");
if (!$execRet) {
$houveErro = true;
}
$execRet = $bd->executaSQL("INSERT INTO articles (title, body) VALUES ('Aluno 02', 'Carlos');");
if (!$execRet) {
$houveErro = true;
}
$execRet = $bd->executaSQL("INSERT INTO articles (title, body) VALUES ('Aluno 03', 'Rafael Garcia');");
if (!$execRet) {
$houveErro = true;
}
$execRet = $bd->executaSQL("INSERT INTO articles (title, body) VALUES ('Aluno 04', 'Deise');");
if (!$execRet) {
$houveErro = true;
}
if ($houveErro) {
$bd->ROLLBACK();
} else {
$bd->commit();
}