/**
  * Binds parameters. This method binds parameters to a PDOStatement for
  * Query Execution. This method binds parameters as NULL, INTEGER or STRING
  * and supports both named keys and question mark keys.
  *
  * @param  PDOStatement $statement  PDO Statement instance
  * @param  array        $bindings   values that need to get bound to the statement
  *
  * @return void
  */
 protected function bindParams($statement, $bindings)
 {
     foreach ($bindings as $key => &$value) {
         if (is_integer($key)) {
             if (is_null($value)) {
                 $statement->bindValue($key + 1, NULL, PDO::PARAM_NULL);
             } elseif (!$this->flagUseStringOnlyBinding && RedBean_QueryWriter_AQueryWriter::canBeTreatedAsInt($value) && $value < 2147483648) {
                 $statement->bindParam($key + 1, $value, PDO::PARAM_INT);
             } else {
                 $statement->bindParam($key + 1, $value, PDO::PARAM_STR);
             }
         } else {
             if (is_null($value)) {
                 $statement->bindValue($key, NULL, PDO::PARAM_NULL);
             } elseif (!$this->flagUseStringOnlyBinding && RedBean_QueryWriter_AQueryWriter::canBeTreatedAsInt($value) && $value < 2147483648) {
                 $statement->bindParam($key, $value, PDO::PARAM_INT);
             } else {
                 $statement->bindParam($key, $value, PDO::PARAM_STR);
             }
         }
     }
 }
Exemple #2
0
 /**
  * Creates a table name based on a types array.
  * Manages the get the correct name for the linking table for the
  * types provided.
  *
  * @todo find a nice way to decouple this class from QueryWriter?
  * 
  * @param array $types 2 types as strings
  *
  * @return string $table table
  */
 public function getTable($types)
 {
     return RedBean_QueryWriter_AQueryWriter::getAssocTableFormat($types);
 }
Exemple #3
0
 /**
  * Determines whether the bea has a shared list based on
  * schema inspection from realtime schema or cache.
  *
  * @param string $type   bean type to get list for
  * @param string $target type of list you are looking for
  *
  * @return boolean
  */
 protected function hasSharedList($type, $target)
 {
     return in_array(RedBean_QueryWriter_AQueryWriter::getAssocTableFormat(array($type, $target)), $this->tables);
 }
 /**
  * @see RedBean_QueryWriter::esc
  */
 public function esc($dbStructure, $noQuotes = FALSE)
 {
     return parent::esc(strtolower($dbStructure), $noQuotes);
 }
Exemple #5
0
 public function __construct(RedBean_Adapter_DBAdapter $adapter)
 {
     $this->adapter = $adapter;
     parent::__construct();
 }
 /**
  * Facade method for RedBean_QueryWriter_AQueryWrite$db->renameAssociation()
  *
  * @param string|array $from
  * @param string       $to
  *
  * @return void
  */
 public function renameAssociation($from, $to = NULL)
 {
     RedBean_QueryWriter_AQueryWriter::renameAssociation($from, $to);
 }
 /**
  * @see RedBean_QueryWriter::deleteRecord
  */
 public function deleteRecord($type, $conditions = array(), $addSql = NULL, $bindings = array())
 {
     parent::deleteRecord($type, $this->filterConditions($conditions), $addSql, $bindings);
 }