public static function get_id_for_name($name)
    {
        $rows = Database_FetchingHelper::get_rows_for_query(new Database_SQLSelectQuery(<<<SQL
SELECT
\tid
FROM
\thpi_trackit_stock_management_images
WHERE
\tname = '{$name}'
SQL
));
        if (count($rows) == 0) {
            /*
             * Add the image.
             */
            return Database_ModifyingStatementHelper::apply_statement(new Database_SQLInsertStatement(<<<SQL
INSERT INTO
\thpi_trackit_stock_management_images
SET
\tname = '{$name}'
SQL
));
        } else {
            $row = $rows[0];
            return $row['id'];
        }
    }
 public function process()
 {
     echo __METHOD__ . "\n";
     echo $this->get_name() . "\n";
     #$products = $this->get_products();
     #print_r($products);
     #foreach ($products as $product) {
     #	$product->delete();
     #}
     $update_statement = $this->get_product_deletion_update_statement();
     $affected_rows = Database_ModifyingStatementHelper::apply_statement($update_statement);
     echo "\$affected_rows: {$affected_rows}\n";
 }
コード例 #3
0
    public function delete()
    {
        #echo __METHOD__ . "\n";
        $product_id = $this->get_product_id();
        #echo "\$product_id: $product_id\n";
        $affected_rows = Database_ModifyingStatementHelper::apply_statement(new Database_SQLUpdateStatement(<<<SQL
UPDATE
\thpi_trackit_stock_management_products
SET
\tdeleted = 'Yes'
WHERE
\tproduct_id = '{$product_id}'
SQL
));
        #echo "\$affected_rows: $affected_rows\n";
    }
    public static function reset_photograph_processing()
    {
        Database_ModifyingStatementHelper::apply_statement(new Database_SQLUpdateStatement(<<<SQL
UPDATE
\thpi_trackit_stock_management_feed_files
SET
\tprocessed = NULL
WHERE
\tfile_type != 'TXT'
\tAND
\tUPPER(name) REGEXP '\\.(JPG|PNG|GIF)\$'
SQL
));
    }