Example #1
0
 public function generateKey()
 {
     $key = "00000";
     $db = new Connection();
     $conn = $db->open();
     $sql = "SELECT id, `key` FROM urlmapping ORDER BY id DESC LIMIT 1";
     $result = $conn->query($sql);
     if ($result->num_rows > 0) {
         while ($row = $result->fetch_assoc()) {
             $key = $row["key"];
         }
     }
     for ($i = 4; $i >= 0; $i--) {
         $ascii = ord($key[$i]);
         if ($ascii < 122) {
             if ($ascii == 57) {
                 $ascii = 65;
             } else {
                 if ($ascii == 90) {
                     $ascii = 97;
                 } else {
                     $ascii++;
                 }
             }
             $key[$i] = chr($ascii);
             break;
         }
         $key[$i] = '0';
     }
     $conn->close();
     return $key;
 }
Example #2
0
 public static function open($database)
 {
     // abre uma conex�o e armazena na propriedade est�tica $conn
     if (empty(self::$conn)) {
         self::$conn = Connection::open($database);
     }
 }
 public static function open($database)
 {
     if (empty(self::$conn)) {
         self::$conn = Connection::open($database);
         self::$conn->beginTransaction();
         self::$logger = NULL;
     }
 }
 public static function location()
 {
     $con = Connection::open();
     $resultado = $con->query("SELECT * FROM producto");
     return $resultado;
 }
 public static function updateColor($id, $selectID, $color_id)
 {
     $con = Connection::open();
     $con->statement("UPDATE color_producto SET id='{$id}' , producto_id='{$selectID}' ,\n\t\t\t\t\t\t\t color_id='{$color_id}' WHERE id='{$id}' AND producto_id='{$selectID}' ");
 }
 public static function deleteProducto($selectID)
 {
     $con = Connection::open();
     $con->statement("DELETE FROM producto WHERE id='{$selectID}' ");
 }
DISCLAIMED. IN NO EVENT SHALL ADRIAN KOSMACZEWSKI BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// The binary plist and the SOAP formatters require huge amounts of memory!
ini_set('memory_limit', '128M');
require_once 'data/database.php';
require_once 'formatters/formatterfactory.php';
// Get all the data from the database
$limit = $_GET["limit"];
if (!$limit) {
    $limit = "50";
}
// Before calling mysql_real_escape_string() you have to connect to the DB...!
$conn = new Connection();
$conn->open();
$query = "SELECT * FROM data ORDER BY RAND() LIMIT " . mysql_real_escape_string($limit);
$data = $conn->execute($query);
$conn->close();
// Depending the "format" parameter in the query string,
// output the data in different formats
$format = mysql_real_escape_string($_GET["format"]);
$formatter = FormatterFactory::createFormatter($format);
$formatter->setData($data);
header('Content-type: ' . $formatter->getContentType());
$output = $formatter->formatData();
echo $output;
 public static function findAll_talla_producto()
 {
     $con = Connection::open();
     $resultado = $con->query("SELECT * FROM talla_producto");
     return $resultado;
 }
 public static function findForSelectID($select)
 {
     $con = Connection::open();
     $resultado = $con->query("SELECT * FROM talla_producto WHERE producto_id='{$select}' ");
     return $resultado;
 }
function execute($query)
{
    $conn = new Connection();
    $conn->open();
    $recordset = $conn->execute($query);
    $conn->close();
    return $recordset;
}
<?php

require_once 'classes/ar/Produto.php';
require_once 'classes/api/Connection.php';
try {
    $conn = Connection::open('estoque');
    Produto::setConnection($conn);
    $pro = new Produto();
    $pro->descricao = 'Café torrado e moído brasileiro';
    $pro->estoque = 100;
    $pro->preco_custo = 4;
    $pro->preco_venda = 7;
    $pro->codigo_barras = '34963045930455';
    $pro->data_cadastro = date('Y-m-d');
    $pro->origem = 'N';
    $pro->save();
} catch (Exception $e) {
    print $e->getMessage();
}
Example #12
0
 /**
  * Create a default connection object
  */
 protected function newConnection()
 {
     $config = $this->config->getGroupConfig();
     $connection = new Connection($config);
     if (isset($config['stricton']) && $config['stricton'] == TRUE) {
         $connection->open();
         $connection->query('SET SESSION sql_mode="STRICT_ALL_TABLES"');
     }
     return $connection;
 }