本文整理汇总了PHP中Connect::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Connect::getInstance方法的具体用法?PHP Connect::getInstance怎么用?PHP Connect::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connect
的用法示例。
在下文中一共展示了Connect::getInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert
public function insert($obj)
{
try {
$query = "INSERT INTO portalleg." . $this->table . " (\n name,\n login,\n mail,\n pass,\n type,\n photo,\n ) VALUES (\n :name,\n :login,\n :mail,\n :pass,\n :type,\n :photo\n )";
$sql = Connect::getInstance()->prepare($query);
$sql->bindValue(':name', $obj->getName(), PDO::PARAM_STR);
$sql->bindValue(':login', $obj->getLogin(), PDO::PARAM_STR);
$sql->bindValue(':mail', $obj->getMail(), PDO::PARAM_STR);
$sql->bindValue(':pass', $obj->getPass(), PDO::PARAM_STR);
$sql->bindValue(':type', $obj->getType(), PDO::PARAM_INT);
$sql->bindValue(':photo', $obj->getPhoto(), PDO::PARAM_STR);
return $sql->execute();
} catch (Exception $e) {
Lib::warning($e);
}
}
示例2: __construct
public function __construct()
{
self::$Connect = Connect::getInstance(DB_NAME, DB_HOST, DB_USER, DB_PASS);
$this->query = isset($this->query) ? $this->query : null;
}
示例3: delete_common
public function delete_common($table, $filters, $query_extra)
{
//criando o objeto pdo...
$pdo = parent::getInstance();
//filtros
foreach ($filters as $key => $value) {
$filters_delete = "{$key}=:{$key} AND ";
}
//removendo ultimo "AND";
$filters_delete = substr($filters_delete, 0, -4);
//preparando query apartir dos campos($fields) e os parametros de valores nomeados($values)
$query = "DELETE FROM {$table} WHERE {$filters_delete};";
//se a consulta precisar de algo mais..
if ($query_extra != "") {
$query .= $query_extra;
}
//echo $query,'<br>';
//continuação da preparação da query...
$statement = $pdo->prepare($query);
if (!$statement) {
echo "\\PDO::errorInfo():\n";
print_r($dbh->errorInfo());
}
//substituindo os parametros dos filtros nomeados pelos verdadeiros valores, ex: ":name" por "Alessandro"
foreach ($filters as $key => $value) {
//$parameters[":$key"] = $value;
$statement->bindValue(":{$key}", $value, PDO::PARAM_STR);
}
//$statement->debugDumpParams();
//executando a query já com seus valores
if ($statement->execute()) {
//se der certo retorna true...
return true;
} else {
//se não der certo, retornará false...
return false;
}
}
示例4: __construct
public function __construct($dbarr = array())
{
$this->connect = Connect::getInstance($dbarr);
}
示例5: __construct
function __construct()
{
$this->db = Connect::getInstance();
}
示例6: find
public function find($value, $by)
{
try {
$sql = "SELECT * FROM " . $this->table . " WHERE " . $by . " = :value";
$sql = Connect::getInstance()->prepare($sql);
$sql->bindValue(":value", $value);
$sql->execute();
return $sql->fetch(PDO::FETCH_ASSOC);
} catch (Exception $e) {
Lib::dbWarning($e);
die;
}
}