Exemple #1
0
 function __construct($table, $db)
 {
     parent::__construct($db);
     $this->method = "Update";
     $this->table = trim($table);
     return $this;
 }
 /** Execute insert query
  * @return integer last inserted id or false
  */
 public function execute()
 {
     $result = parent::execute();
     if ($result) {
         return $this->getPDO()->lastInsertId();
     }
     return false;
 }
 function setUp()
 {
     $this->table = DummyDatabaseObject::$table;
     $this->fields = DummyDatabaseObject::$fields;
     $this->pk = DummyDatabaseObject::$primary_key;
     $this->fields_str = BaseQuery::fields_to_sql($this->fields, $this->table);
     $dbobj = new DummyDatabaseObject();
     $this->sqlobj = new SelectQuery($dbobj);
 }
Exemple #4
0
 function __construct($columns = "*", $db)
 {
     parent::__construct($db);
     $this->method = "SELECT";
     if (is_array($columns)) {
         $columns = implode(", ", $columns);
     }
     $this->columns = $columns;
     return $this;
 }
 function setUp()
 {
     $this->table = DummyDatabaseObject::$table;
     $this->fields = DummyDatabaseObject::$fields;
     $this->pk = DummyDatabaseObject::$primary_key;
     $this->fields_str = BaseQuery::fields_to_sql($this->fields, $this->table);
     $this->testString = "UPDATE {$this->table} SET testfield2 = :testField2";
     $this->testValues = array('tfield1' => 'Blub', 'testField2' => 'Bluu');
     $this->testResultValues = array(':testField2' => 'Bluu');
     $this->sqlobj = new UpdateQuery(new DummyDatabaseObject());
 }
 /**
  * {@inheritdoc}
  */
 public function isExists()
 {
     $data = $this->queryDriver->selectQuery();
     if (!$data) {
         return null;
     }
     if (null !== $data['ttl']) {
         $now = new \DateTime('now');
         $ttl = new \DateTime($data['ttl']);
         if ($ttl < $now) {
             return $this->createUnlock();
         }
     }
     return true;
 }
Exemple #7
0
 public function save($con = null)
 {
     // if the first save
     $going_to_save = !$this->getId();
     parent::save($con);
     // if it is the first then connect to google
     // for the queries and get the results.
     if ($going_to_save) {
         $query_result = new QueryResultBulk();
         $query_result->setQuery($this);
         //$searchEngine = new GoogleRegexp();
         //$count = $searchEngine->search($this->getQuery());
         $searchEngine = new GoogleHitFetcher();
         $count = $searchEngine->fetch($this->getQuery());
         $query_result->setResultSize($count);
         $query_result->save();
     }
 }
Exemple #8
0
 /**
  * @return string
  */
 protected function buildQuery()
 {
     # first create extra join from statements with columns with referenced tables
     $statementsWithReferences = array('WHERE', 'SELECT', 'GROUP BY', 'ORDER BY');
     foreach ($statementsWithReferences as $clause) {
         if (array_key_exists($clause, $this->statements)) {
             $this->statements[$clause] = array_map(array($this, 'createUndefinedJoins'), $this->statements[$clause]);
         }
     }
     return parent::buildQuery();
 }
Exemple #9
0
 protected function buildParameters()
 {
     $this->parameters = array_merge($this->filterLiterals($this->statements['VALUES']), $this->filterLiterals($this->statements['ON DUPLICATE KEY UPDATE']));
     return parent::buildParameters();
 }
Exemple #10
0
 public function __construct(\CventQuery\CventConnection $connection)
 {
     parent::__construct($connection, self::RETRIEVE_CALL_NAME);
     $this->ids = [];
 }
 public function __construct(\PDOException $pdoEx, \BaseQuery $query)
 {
     $queryString = str_ireplace(array("\n", "\t", PHP_EOL), " ", $query->getQuery());
     parent::__construct("[SQL Error #{$pdoEx->getCode()}] - {$pdoEx->getMessage()}. Failed to execute query" . PHP_EOL . "\t{$queryString}." . PHP_EOL);
 }