本文整理汇总了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();
}