php Judy_Hopps_II
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Judy_Hopps_II相关的知识,希望对你有一定的参考价值。
<?php
class harry_potter {
const Database = 'php';
const username = 'root';
const password = '';
const Server = 'localhost';
public $array;
public $tablename = "";
public $msg_ins = "";
public $msg_up = "";
public $db = "";
public $localhost = "";
public $pas = "";
public $user = "";
public $id_up = ""; //اسم المستخدم
public $ok = false;
public function __construct($table, Array $value)
{
$this->localhost = harry_potter::Server;
$this->user = harry_potter::username;
$this->pas = harry_potter::password;
$this->db = harry_potter::Database;
$this->tablename = $table;
$this->tablename = $table;
$this->array = $value;
}
function get_num_of_words($string)
{
$string = preg_replace('/\s+/', ' ', trim($string));
$words = explode(" ", $string);
return count($words);
}
public function up_col_2_Basic($var1, $id)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $var1, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
$this->msg_up;
}
}
} catch (PDOException $exc) {
$exc->getMessage();
}
}
public function up_col_3($var1, $var2, $id)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $var1, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $var2, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function up_col_4($var1, $var2, $var3, $id)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2, `$coulam3` = :$coulam3 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $var1, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $var2, PDO::PARAM_STR);
$statement->bindValue(":$coulam3", $var3, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function up_col_5($var1, $var2, $var3, $var4, $id)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2, `$coulam3` = :$coulam3, `$coulam4` = :$coulam4 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $var1, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $var2, PDO::PARAM_STR);
$statement->bindValue(":$coulam3", $var3, PDO::PARAM_STR);
$statement->bindValue(":$coulam4", $var4, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function up_col_6($var1, $var2, $var3, $var4, $var5, $id)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2, `$coulam3` = :$coulam3, `$coulam4` = :$coulam4, `$coulam5` = :$coulam5 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $var1, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $var2, PDO::PARAM_STR);
$statement->bindValue(":$coulam3", $var3, PDO::PARAM_STR);
$statement->bindValue(":$coulam4", $var4, PDO::PARAM_STR);
$statement->bindValue(":$coulam5", $var5, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function up_col_7($var1, $var2, $var3, $var4, $var5, $var6, $id)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
$coulam6 = $column[6];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2, `$coulam3` = :$coulam3, `$coulam4` = :$coulam4, `$coulam5` = :$coulam5 , `$coulam6` = :$coulam6 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $var1, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $var2, PDO::PARAM_STR);
$statement->bindValue(":$coulam3", $var3, PDO::PARAM_STR);
$statement->bindValue(":$coulam4", $var4, PDO::PARAM_STR);
$statement->bindValue(":$coulam5", $var5, PDO::PARAM_STR);
$statement->bindValue(":$coulam6", $var6, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function up_col_8($var1, $var2, $var3, $var4, $var5, $var6, $var7, $id)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam6 = $column[6];
$coulam7 = $column[7];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2, `$coulam3` = :$coulam3, `$coulam4` = :$coulam4, `$coulam5` = :$coulam5 , `$coulam6` = :$coulam6, `$coulam7` = :$coulam7 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $var1, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $var2, PDO::PARAM_STR);
$statement->bindValue(":$coulam3", $var3, PDO::PARAM_STR);
$statement->bindValue(":$coulam4", $var4, PDO::PARAM_STR);
$statement->bindValue(":$coulam5", $var5, PDO::PARAM_STR);
$statement->bindValue(":$coulam6", $var6, PDO::PARAM_STR);
$statement->bindValue(":$coulam7", $var7, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function con_db()
{
try {
// jjjjj "mysql:host=$this->localhost;dbname=$this->db";
// "<br>" . $this->user, $this->pas + "<br>";
$cnn = new PDO("mysql:host=$this->localhost;dbname=$this->db;charset=utf8", $this->user, $this->pas);
$cnn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$cnn->exec('SEt NAMES utf8');
"CONECT OK";
return $cnn;
} catch (PDOException $exc) {
echo 'NOT conected' . $exc->getMessage();
}
}
public function Malcom_xx_up($id)
{
$keys = array_keys($this->array);
$count = count($this->array);
if ($count == 2)
{
$valyes = array_values($this->array);
$val = $valyes[1];
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $val, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($count == 3)
{
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $val2, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $val3, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($count == 4)
{
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2, `$coulam3` = :$coulam3 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $val2, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $val3, PDO::PARAM_STR);
$statement->bindValue(":$coulam3", $val4, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($count == 5)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2, `$coulam3` = :$coulam3, `$coulam4` = :$coulam4 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $val2, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $val3, PDO::PARAM_STR);
$statement->bindValue(":$coulam3", $val4, PDO::PARAM_STR);
$statement->bindValue(":$coulam4", $val5, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($count == 6)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
$val6 = $valyes[5];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2, `$coulam3` = :$coulam3, `$coulam4` = :$coulam4, `$coulam5` = :$coulam5 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $val2, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $val3, PDO::PARAM_STR);
$statement->bindValue(":$coulam3", $val4, PDO::PARAM_STR);
$statement->bindValue(":$coulam4", $val5, PDO::PARAM_STR);
$statement->bindValue(":$coulam5", $val6, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($count == 7)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
$coulam6 = $column[6];
//----------------------------------------------------------
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
$val6 = $valyes[5];
$val7 = $valyes[6];
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2, `$coulam3` = :$coulam3, `$coulam4` = :$coulam4, `$coulam5` = :$coulam5 , `$coulam6` = :$coulam6 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $val2, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $val3, PDO::PARAM_STR);
$statement->bindValue(":$coulam3", $val4, PDO::PARAM_STR);
$statement->bindValue(":$coulam4", $val5, PDO::PARAM_STR);
$statement->bindValue(":$coulam5", $val6, PDO::PARAM_STR);
$statement->bindValue(":$coulam6", $val7, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($count == 8)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
$coulam6 = $column[6];
$coulam7 = $column[7];
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
$val6 = $valyes[5];
$val7 = $valyes[6];
$val8 = $valyes[7];
//----------------------------------------------------------
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2, `$coulam3` = :$coulam3, `$coulam4` = :$coulam4, `$coulam5` = :$coulam5 , `$coulam6` = :$coulam6, `$coulam7` = :$coulam7 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $val2, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $val3, PDO::PARAM_STR);
$statement->bindValue(":$coulam3", $val4, PDO::PARAM_STR);
$statement->bindValue(":$coulam4", $val5, PDO::PARAM_STR);
$statement->bindValue(":$coulam5", $val6, PDO::PARAM_STR);
$statement->bindValue(":$coulam6", $val7, PDO::PARAM_STR);
$statement->bindValue(":$coulam7", $val8, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($count == 9)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
$coulam6 = $column[6];
$coulam7 = $column[7];
$coulam8 = $column[8];
//----------------------------------------------------------
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
$val6 = $valyes[5];
$val7 = $valyes[6];
$val8 = $valyes[7];
$val9 = $valyes[8];
$sql = "UPDATE `$tablename` SET `$coulam1` = :$coulam1, `$coulam2` = :$coulam2, `$coulam3` = :$coulam3, `$coulam4` = :$coulam4, `$coulam5` = :$coulam5 , `$coulam6` = :$coulam6, `$coulam7` = :$coulam7, `$coulam8` = :$coulam8 WHERE `id` = :id;";
$con = $this->con_db();
if ($statement = $con->prepare($sql))
{
$statement->bindValue(":$coulam1", $val2, PDO::PARAM_STR);
$statement->bindValue(":$coulam2", $val3, PDO::PARAM_STR);
$statement->bindValue(":$coulam3", $val4, PDO::PARAM_STR);
$statement->bindValue(":$coulam4", $val5, PDO::PARAM_STR);
$statement->bindValue(":$coulam5", $val6, PDO::PARAM_STR);
$statement->bindValue(":$coulam6", $val7, PDO::PARAM_STR);
$statement->bindValue(":$coulam7", $val8, PDO::PARAM_STR);
$statement->bindValue(":$coulam8", $val9, PDO::PARAM_STR);
$statement->bindValue(":id", $id, PDO::PARAM_INT);
if ($statement->execute())
{
echo $this->msg_up;
}
}
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
//----------------------------------------------------------
}
public function Malcom_xx_ins()
{
$keys = array_keys($this->array);
$count = count($this->array);
$count;
if ($count == 1)
{
$string = array_values($this->array);
$string[0];
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
try {
$val = $string[0];
$string_SQL = "INSERT INTO `$tablename` ($coulam1 ) VALUES (?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $val, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
else
{
echo "Input failure to the database";
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
$cdn = NULL;
}
elseif ($count == 2)
{
$string = array_values($this->array);
$val = $string[0];
$val2 = $string[1];
//كده البحث عن عمودين
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
//----------------------------------------------------------
try {
$string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2) VALUES (?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
else
{
echo "Input failure to the database";
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
$cdn = NULL;
}
elseif ($count == 3)
{
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
//----------------------------------------------------------
try {
$string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2,$coulam3) VALUES (?, ?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->bindParam(3, $val3, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
//كده البحث عن ثلاثة اعمدة
}
elseif
($count == 4)
{
$count;
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
//----------------------------------------------------------
try {
$string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2,$coulam3,$coulam4) VALUES (?, ?, ?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->bindParam(3, $val3, PDO::PARAM_STR);
$sth->bindParam(4, $val4, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
//كده البحث عن اربع اعمدة
}
elseif ($count == 5)
{
//كده البحث عن خمس اعمدة
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
//----------------------------------------------------------
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
try {
$string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2,$coulam3,$coulam4,$coulam5) VALUES (?, ?, ?, ?, ?)";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->bindParam(3, $val3, PDO::PARAM_STR);
$sth->bindParam(4, $val4, PDO::PARAM_STR);
$sth->bindParam(5, $val5, PDO::PARAM_STR);
if ($sth->execute())
{
echo "insert data";
}
} catch (PDOException $ex) {
echo $ex->getMessage() . "err";
}
}
elseif ($count == 6)
{
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
$val6 = $valyes[5];
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
$coulam6 = $column[6];
//----------------------------------------------------------
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
$val6 = $valyes[5];
try {
$string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2,$coulam3,$coulam4,$coulam5,$coulam6) VALUES (?, ?, ?, ?, ?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->bindParam(3, $val3, PDO::PARAM_STR);
$sth->bindParam(4, $val4, PDO::PARAM_STR);
$sth->bindParam(5, $val5, PDO::PARAM_STR);
$sth->bindParam(6, $val6, PDO::PARAM_STR);
if ($sth->execute())
{
$this->msg_ins;
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
}
elseif ($count == 7)
{
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
$coulam6 = $column[6];
$coulam7 = $column[7];
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
$val6 = $valyes[5];
$val7 = $valyes[6];
//----------------------------------------------------------
try {
$string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2,$coulam3,$coulam4,$coulam5,$coulam6,$coulam7) VALUES (?, ?, ?, ?, ?, ?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->bindParam(3, $val3, PDO::PARAM_STR);
$sth->bindParam(4, $val4, PDO::PARAM_STR);
$sth->bindParam(5, $val5, PDO::PARAM_STR);
$sth->bindParam(6, $val6, PDO::PARAM_STR);
$sth->bindParam(7, $val7, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
}
elseif ($count == 8)
{
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
$coulam6 = $column[6];
$coulam7 = $column[7];
$coulam8 = $column[8];
//----------------------------------------------------------
try {
$valyes = array_values($this->array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
$val6 = $valyes[5];
$val7 = $valyes[6];
$val8 = $valyes[7];
$string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2,$coulam3,$coulam4,$coulam5,$coulam6,$coulam7,$coulam8) VALUES (?, ?, ?, ?, ?, ?, ?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->bindParam(3, $val3, PDO::PARAM_STR);
$sth->bindParam(4, $val4, PDO::PARAM_STR);
$sth->bindParam(5, $val5, PDO::PARAM_STR);
$sth->bindParam(6, $val6, PDO::PARAM_STR);
$sth->bindParam(7, $val7, PDO::PARAM_STR);
$sth->bindParam(8, $val8, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
}
}
public function rows_Duplicate($Query)
{
// $Query = "select * from positive where positive = 'col1' and Address = 'col2'";
$sql_con = $this->con_db();
// echo $Query;
$queryResult = $sql_con->query($Query);
$foundRows = $queryResult->rowCount();
if ($foundRows >= 1)
{
}
else
{
$this->Malcom_xx_ins();
}
}
function DuplicateMySQLRecord($table, $id_field, $id)
{
$sql_con = $this->con_db();
$result = $sql_con->query("SELECT * FROM " . $table . "
WHERE " . $id_field . " = '" . $id . "' LIMIT 1");
$row = $result[0];
}
public function count_rows($Query)
{
$dbh = $this->con_db();
$sql = $Query;
$stmt = $dbh->prepare($sql);
try {
$stmt->execute();
} catch (PDOException $e) {
echo $e->getMessage();
}
return $stmt->rowCount();
}
public function count_rows_cond($Query, $array)
{
$dbh = $this->con_db();
$sql = $Query;
$stmt = $dbh->prepare($sql);
try {
$stmt->execute($array);
} catch (PDOException $e) {
echo $e->getMessage();
}
return $stmt->rowCount();
}
public function Field_Protection($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
public function General_extraction($Query)
{
$con = new PDO("mysql:host=$this->localhost;dbname=$this->db", "$this->user", $this->pas);
$con->query("SET NAMES utf8");
$sth = $con->prepare($Query);
$sth->execute();
return $result = $sth->fetchAll();
}
public function General_extraction_Row($Query)
{
$con = new PDO("mysql:host=$this->localhost;dbname=$this->db", "$this->user", $this->pas);
$con->query("SET NAMES utf8");
$sth = $con->prepare($Query);
$sth->execute();
return $result = $sth->fetch();
}
public function General_extraction_ADV($Query, $array)
{
/*
* وضع الأستعلام في مصفوفة
*/
$arr = array($Query);
/*
* الخطو الثانية ايجاد عدد مرات الأستبدال
*/
str_ireplace("?", "?", $arr, $i);
$i;
/*
* الأتصال بقاعدة البيانات
*/
$con = new PDO("mysql:host=$this->localhost;dbname=$this->db", $this->user, $this->pas);
/*
*
*/
/*
* وضع شرط لعدد مرات الأستبدال
*/
if ($i = 1)
{
try {
$valyes = array_values($array);
$val = $valyes[0];
$val2 = $valyes[1];
$sth = $con->prepare($Query);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($i = 2)
{
try {
$valyes = array_values($array);
print_r($valyes);
$val = $valyes[0];
$val2 = $valyes[1];
$sth = $con->prepare($Query);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($i = 3)
{
try {
$valyes = array_values($array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$sth = $con->prepare($Query);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->bindParam(3, $val3, PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($i = 4)
{
try {
$valyes = array_values($array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$sth = $con->prepare($Query);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->bindParam(3, $val3, PDO::PARAM_STR);
$sth->bindParam(4, $val4, PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($i = 5)
{
try {
$valyes = array_values($array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
$sth = $con->prepare($Query);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->bindParam(3, $val3, PDO::PARAM_STR);
$sth->bindParam(4, $val4, PDO::PARAM_STR);
$sth->bindParam(5, $val5, PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
elseif ($i = 6)
{
try {
$valyes = array_values($array);
$val = $valyes[0];
$val2 = $valyes[1];
$val3 = $valyes[2];
$val4 = $valyes[3];
$val5 = $valyes[4];
$val6 = $valyes[6];
$sth = $con->prepare($Query);
$sth->bindParam(1, $val, PDO::PARAM_STR);
$sth->bindParam(2, $val2, PDO::PARAM_STR);
$sth->bindParam(3, $val3, PDO::PARAM_STR);
$sth->bindParam(4, $val4, PDO::PARAM_STR);
$sth->bindParam(5, $val5, PDO::PARAM_STR);
$sth->bindParam(5, $val6, PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
}
public function strlen($val, $lenth)
{
$this->Field_Protection($val);
if (strlen($this->$val) < $lenth)
{
return $ok = FALSE;
}
else
{
return $ok = TRUE;
}
}
public function emp($val)
{
$this->Field_Protection($val);
if (empty($this->Field_Protection($val)))
{
return 1;
}
else
{
return 2;
}
}
public function validateEmail($email, $inp_nam)
{
$this->Field_Protection($email);
if (!filter_input(INPUT_POST, $inp_nam, FILTER_VALIDATE_EMAIL))
{
return $ok = FALSE;
}
else
{
return $ok = TRUE;
}
}
public function validate_url($url, $inp_nam)
{
$this->Field_Protection($url);
if (!filter_input(INPUT_POST, $inp_nam, FILTER_VALIDATE_URL))
{
return $ok = 1;
}
else
{
return $ok = 2;
}
}
public function PAS_INT($PAS, $msg, $inp_nam)
{
$this->Field_Protection($PAS);
if (!filter_input(INPUT_POST, $inp_nam, FILTER_VALIDATE_INT))
{
return $ok = FALSE;
}
else
{
return $ok = TRUE;
}
}
public function isValidEmail($email)
{
$this->Field_Protection($email);
$pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
if (eregi($pattern, $email))
{
return $ok = TRUE;
}
else
{
return $ok = FALSE;
}
}
public function PAS_Match($val1, $val2, $true, $false)
{
$this->Field_Protection($val1);
$this->Field_Protection($val2);
if ($val1 == $val2)
{
return $ok = TRUE;
}
else
{
return $ok = FALSE;
}
}
public function opt_email($email, $true, $false, $opt)
{
$this->Field_Protection($email);
if ($opt = 1)
{
$val = strtolower($email);
$text1 = "@yahoo.com";
if (stristr($text, $val))
{
return $ok = TRUE;
}
else
{
return $ok = FALSE;
}
}
elseif ($opt = 2)
{
if ($opt = 1)
{
$val = strtolower($email);
$text1 = "@gmail.com";
if (stristr($text, $val))
{
return $ok = TRUE;
}
else
{
return $ok = FALSE;
}
}
}
}
public function serch_db_col_BAC($keyword, $col)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$sql = "SELECT * FROM `$this->tablename` WHERE `$col` LIKE ? ;";
$sth = $cdn->prepare($sql);
$sth->bindValue(1, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function serch_db_col1($keyword)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$sql = "SELECT * FROM `$this->tablename` WHERE `$coulam1` LIKE ? ;";
$sth = $cdn->prepare($sql);
$sth->bindValue(1, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function serch_db_col2($keyword)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$sql = "SELECT * FROM `$this->tablename` WHERE `$coulam1` LIKE ? UNION "
. "SELECT * FROM `$this->tablename` WHERE `$coulam2` LIKE ?;";
$sth = $cdn->prepare($sql);
$sth->bindValue(1, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(2, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function serch_db_col3($keyword)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$sql = "SELECT * FROM `$this->tablename` WHERE `$coulam1` LIKE ? UNION "
. "SELECT * FROM `$this->tablename` WHERE `$coulam2` LIKE ?;"
. "SELECT * FROM `$this->tablename` WHERE `$coulam3` LIKE ?";
$sth = $cdn->prepare($sql);
$sth->bindValue(1, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(2, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(3, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function serch_db_col4($keyword)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$sql = "SELECT * FROM `$this->tablename` WHERE `$coulam1` LIKE ? UNION "
. "SELECT * FROM `$this->tablename` WHERE `$coulam2` LIKE ?;"
. "SELECT * FROM `$this->tablename` WHERE `$coulam3` LIKE ?"
. "SELECT * FROM `$this->tablename` WHERE `$coulam4` LIKE ?";
$sth = $cdn->prepare($sql);
$sth->bindValue(1, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(2, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(3, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function serch_db_col5($keyword)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
$sql = "SELECT * FROM `$this->tablename` WHERE `$coulam1` LIKE ? UNION "
. "SELECT * FROM `$this->tablename` WHERE `$coulam2` LIKE ?;"
. "SELECT * FROM `$this->tablename` WHERE `$coulam3` LIKE ?"
. "SELECT * FROM `$this->tablename` WHERE `$coulam4` LIKE ?"
. "SELECT * FROM `$this->tablename` WHERE `$coulam5` LIKE ?";
$sth = $cdn->prepare($sql);
$sth->bindValue(1, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(2, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(3, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(4, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(5, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function serch_db_col6($keyword)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
$coulam6 = $column[6];
$sql = "SELECT * FROM `$this->tablename` WHERE `$coulam1` LIKE ? UNION "
. "SELECT * FROM `$this->tablename` WHERE `$coulam2` LIKE ?;"
. "SELECT * FROM `$this->tablename` WHERE `$coulam3` LIKE ?"
. "SELECT * FROM `$this->tablename` WHERE `$coulam4` LIKE ?"
. "SELECT * FROM `$this->tablename` WHERE `$coulam5` LIKE ?"
. "SELECT * FROM `$this->tablename` WHERE `$coulam6` LIKE ?";
$sth = $cdn->prepare($sql);
$sth->bindValue(1, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(2, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(3, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(4, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(5, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(6, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function serch_db_col7($keyword)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
$coulam1 = $column[1];
$coulam2 = $column[2];
$coulam3 = $column[3];
$coulam4 = $column[4];
$coulam5 = $column[5];
$coulam6 = $column[6];
$coulam7 = $column[7];
$sql = "SELECT * FROM `$this->tablename` WHERE `$coulam1` LIKE ? UNION "
. "SELECT * FROM `$this->tablename` WHERE `$coulam2` LIKE ?;"
. "SELECT * FROM `$this->tablename` WHERE `$coulam3` LIKE ?"
. "SELECT * FROM `$this->tablename` WHERE `$coulam4` LIKE ?"
. "SELECT * FROM `$this->tablename` WHERE `$coulam5` LIKE ?"
. "SELECT * FROM `$this->tablename` WHERE `$coulam6` LIKE ?"
. "SELECT * FROM `$this->tablename` WHERE `$coulam7` LIKE ?";
$sth = $cdn->prepare($sql);
$sth->bindValue(1, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(2, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(3, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(4, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(5, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(6, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->bindValue(7, '%' . $keyword . '%', PDO::PARAM_STR);
$sth->execute();
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
public function del_row($id)
{
try {
$con = $this->con_db();
if ($query = $con->prepare("DELETE FROM $this->tablename WHERE id=?"))
;
$query->bindValue(1, $id, PDO::PARAM_INT);
if ($query->execute())
{
$this->msg_del;
}
} catch (PDOException $ex) {
echo $ex;
}
}
public function General_extraction_array($Query, $array)
{
$con = new PDO("mysql:host=$this->localhost;charset=utf8;dbname=$this->db", $this->user, $this->pas);
try {
$sth = $con->prepare($Query);
$sth->execute($array);
return $result = $sth->fetchAll();
} catch (PDOException $exc) {
echo $exc->getMessage();
}
}
function highlightWords($string, $word)
{
$string = str_replace($word, "<span class='highlight'>" . $word . "</span>", $string);
/* * * return the highlighted string ** */
return $string;
}
function truncateTable($tabel)
{
try {
// echo "TRUNCATE TABLE $this->tablename";
// echo "Truncating..";
$cdn = $this->con_db();
$query = $cdn->exec("TRUNCATE TABLE $tabel");
// echo "Truncated table $tblname!";
} catch (PDOException $ex) {
//echo $ex;
}
}
public function ins_col_2($var1)
{
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
echo "<br>";
$coulam1 = $column[1];
"<br>";
//----------------------------------------------------------
try {
echo $string_SQL = "INSERT INTO `$tablename` ($coulam1 ) VALUES (?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $var1, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
else
{
echo "Input failure to the database";
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
$cdn = NULL;
}
public function ins_col_3($var1, $var2)
{
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
echo "<br>";
$coulam1 = $column[1];
"<br>";
$coulam2 = $column[2];
echo "<br>";
//----------------------------------------------------------
try {
echo $string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2) VALUES (?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $var1, PDO::PARAM_STR);
$sth->bindParam(2, $var2, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
else
{
echo "Input failure to the database";
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
$cdn = NULL;
}
public function ins_col_4($var1, $var2, $var3)
{
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
echo "<br>";
$coulam1 = $column[1];
"<br>";
$coulam2 = $column[2];
echo "<br>";
$coulam3 = $column[3];
echo "<br>";
//----------------------------------------------------------
try {
echo $string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2,$coulam3) VALUES (?, ?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $var1, PDO::PARAM_STR);
$sth->bindParam(2, $var2, PDO::PARAM_STR);
$sth->bindParam(3, $var3, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
}
public function ins_col_5($var1, $var2, $var3, $var4)
{
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
echo "<br>";
$coulam1 = $column[1];
"<br>";
$coulam2 = $column[2];
echo "<br>";
$coulam3 = $column[3];
echo "<br>";
$coulam4 = $column[4];
echo "<br>";
//----------------------------------------------------------
try {
echo $string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2,$coulam3,$coulam4) VALUES (?, ?, ?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $var1, PDO::PARAM_STR);
$sth->bindParam(2, $var2, PDO::PARAM_STR);
$sth->bindParam(3, $var3, PDO::PARAM_STR);
$sth->bindParam(4, $var4, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
}
public function ins_col_6($var1, $var2, $var3, $var4, $var5)
{
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
echo "<br>";
$coulam1 = $column[1];
"<br>";
$coulam2 = $column[2];
echo "<br>";
$coulam3 = $column[3];
echo "<br>";
$coulam4 = $column[4];
echo "<br>";
$coulam5 = $column[5];
echo "<br>";
//----------------------------------------------------------
try {
echo $string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2,$coulam3,$coulam4,$coulam5) VALUES (?, ?, ?, ?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $var1, PDO::PARAM_STR);
$sth->bindParam(2, $var2, PDO::PARAM_STR);
$sth->bindParam(3, $var3, PDO::PARAM_STR);
$sth->bindParam(4, $var4, PDO::PARAM_STR);
$sth->bindParam(5, $var5, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
} catch (PDOException $ex) {
echo $ex->getMessage() . "err";
}
}
public function ins_col_7($var1, $var2, $var3, $var4, $var5, $var6)
{
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
echo "<br>";
$coulam1 = $column[1];
"<br>";
$coulam2 = $column[2];
echo "<br>";
$coulam3 = $column[3];
echo "<br>";
$coulam4 = $column[4];
echo "<br>";
$coulam5 = $column[5];
echo "<br>";
$coulam6 = $column[6];
echo "<br>";
//----------------------------------------------------------
try {
echo $string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2,$coulam3,$coulam4,$coulam5,$coulam6) VALUES (?, ?, ?, ?, ?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $var1, PDO::PARAM_STR);
$sth->bindParam(2, $var2, PDO::PARAM_STR);
$sth->bindParam(3, $var3, PDO::PARAM_STR);
$sth->bindParam(4, $var4, PDO::PARAM_STR);
$sth->bindParam(5, $var5, PDO::PARAM_STR);
$sth->bindParam(6, $var6, PDO::PARAM_STR);
if ($sth->execute())
{
echo "Has been added to the statement";
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
}
public function ins_col_8($var1, $var2, $var3, $var4, $var5, $var6, $var7)
{
$cdn = $this->con_db();
$tablename = $this->tablename;
$select = $cdn->query('SELECT * FROM ' . $tablename);
$total_column = $select->columnCount();
for ($counter = 0; $counter <= $total_column; $counter ++)
{
$meta = $select->getColumnMeta($counter);
$column[] = $meta['name'];
}
$coulam = $column[0];
echo "<br>";
$coulam1 = $column[1];
"<br>";
$coulam2 = $column[2];
echo "<br>";
$coulam3 = $column[3];
echo "<br>";
$coulam4 = $column[4];
echo "<br>";
$coulam5 = $column[5];
echo "<br>";
$coulam6 = $column[6];
echo "<br>";
$coulam7 = $column[7];
echo "<br>";
echo "<br>";
//----------------------------------------------------------
try {
echo $string_SQL = "INSERT INTO `$tablename` ($coulam1 ,$coulam2,$coulam3,$coulam4,$coulam5,$coulam6,$coulam7) VALUES (?, ?, ?, ?, ?, ?, ?);";
$sth = $cdn->prepare($string_SQL);
$sth->bindParam(1, $var1, PDO::PARAM_STR);
$sth->bindParam(2, $var2, PDO::PARAM_STR);
$sth->bindParam(3, $var3, PDO::PARAM_STR);
$sth->bindParam(4, $var4, PDO::PARAM_STR);
$sth->bindParam(5, $var5, PDO::PARAM_STR);
$sth->bindParam(6, $var6, PDO::PARAM_STR);
$sth->bindParam(7, $var6, PDO::PARAM_STR);
if ($sth->execute())
{
echo $this->msg_ins;
}
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
}
public function db_rows($coulam, $input)
{
try {
$cdn = $this->con_db();
$tablename = $this->tablename;
$stmt = $cdn->prepare("SELECT count(*) from $tablename WHERE $coulam = :steam_id");
$stmt->bindValue(':steam_id', $input);
$stmt->execute();
$count = $stmt->fetchColumn();
return $count;
} catch (PDOException $ex) {
$ex->getMessage() . "err";
}
}
}
class pagination_bootstrap extends harry_potter {
public function pagnation($pag_name, $number_pag)
{
error_reporting("E_ALL & ~E_NOTIC");
$con = $this->con_db();
$get_page = $_GET['id'];
$numpag = $number_pag; //كم عدد النتئاج المعروضة في الصفحة
$pagname = $pag_name;
$rows = $this->count_rows("select * from $this->tablename");
$len = (int) ceil($rows / $numpag);
if (!$get_page)
{
$get_page = 0;
}
$string_sql = "select * from $this->tablename limit $get_page,$numpag";
$quuery = $con->query($string_sql);
$x = $quuery->fetchAll(PDO::FETCH_ASSOC);
return array($len, $x, $numpag);
}
public function pagnation2($pag_name, $number_pag, $pagname)
{
error_reporting("E_ALL & ~E_NOTIC");
$con = $this->con_db();
$numpag = $number_pag; //كم عدد النتئاج المعروضة في الصفحة
$rows = $this->count_rows("select * from $this->tablename");
$len = intval($rows / $numpag);
if (!$get_page)
{
$get_page = 0;
}
$start = ($pagname - 1) * $numpag;
$string_sql = "select * from $this->tablename limit $start,$numpag";
$quuery = $con->query($string_sql);
$x = $quuery->fetchAll(PDO::FETCH_ASSOC);
return array($len, $x, $numpag);
}
}
?>
以上是关于php Judy_Hopps_II的主要内容,如果未能解决你的问题,请参考以下文章
php [guzzle php] guzzle php #php
IntelliJ IDEA 11编辑php是,支持php文件名为.php5和.php4,如何设置能让其也支持.php呢?